Express-style Path to RegExp Utility
JSON →path-to-regexp is a robust JavaScript/TypeScript utility for converting Express-style path strings, such as `/user/:name`, into regular expressions. It is widely used in routing libraries to match URLs against defined patterns, supporting features like named parameters (`:foo`), wildcards (`*splat`), and optional segments (`{/:id}`). The library also provides reverse functionality through its `compile` and `stringify` methods, allowing parameters to be transformed back into path strings. Currently at version `8.4.2`, it maintains an active development cadence with regular updates focusing on performance enhancements, bundle size reduction, and critical security fixes. Its primary differentiator is its comprehensive feature set for complex path matching and generation, making it a foundational component for many web frameworks and routers. It explicitly states its purpose for ordered data like paths, not arbitrary data like query strings. This package ships with TypeScript types.
Traffic · last 30 days ↑67% vs prev 7d
top countries 🇺🇸 United States · 🇫🇷 France · 🇨🇦 Canada · 🇨🇭 Switzerland · 🇳🇴 Norway