pillarjs

pillarjs/path-to-regexp

TypeScript MIT Web Dev

Turn a path string such as `/user/:name` into a regular expression

8.6k stars
487 forks
recent
GitHub +1 / week

8.6k

Stars

487

Forks

13

Open issues

30

Contributors

v8.4.2 01 Apr 2026

AI Analysis

path-to-regexp converts path strings with parameters (like `/user/:name`) into regular expressions for routing. It is a foundational utility library widely used in Node.js web frameworks, particularly Express.js, to parse and match URL paths. It serves developers building HTTP routers and URL matching systems, not end-users or general audiences.

Web Dev Library Discovery value: 2/10
Documentation 8/10
Activity 8/10
Community 9/10
Code quality 7/10

Inferred from signals mentioned in the README (tests, CI, type safety) — not a review of the actual code.

Overall score 8/10

AI's overall editorial judgment — not an average of the bars above, can weigh other factors too.

url-routing path-parsing regex-generation nodejs-utility express-ecosystem
MIT licensed Actively maintained Well documented Popular Niche/specialized use case Production ready
Deep Analysis · Based on README and public signals
2w ago

path-to-regexp: The URL routing primitive quietly powering most of the Node.js ecosystem

path-to-regexp converts URL path strings like `/user/:name` into regular expressions, enabling named parameter extraction, optional segments, and wildcard matching. It is a foundational dependency used internally by Express.js, Koa, and numerous other routing frameworks, meaning most Node.js applications rely on it indirectly. Its primary audience is framework authors and developers building custom routers or middleware. The library has stabilized around a clean API with `match`, `compile`, `parse`, and `stringify` functions, making it useful both as a direct tool and as an embedded routing primitive.

Origin

Created in August 2012 under the pillarjs organization (closely linked to Express.js development), it has evolved over 13+ years from a simple regex utility into a well-specified routing primitive, with breaking changes over major versions tightening syntax to reduce ambiguity.

Growth

Growth is largely structural: as Express.js adoption grew globally, path-to-regexp was pulled along as a transitive dependency. Direct stars (8,597) underrepresent actual reach — npm download counts are in the hundreds of millions per month. Recent star velocity (2/week as of mid-2026) reflects saturation, not decline. The library is in a maintenance phase appropriate for its maturity.

In production

Strong indirect adoption evidence: path-to-regexp is a direct dependency of Express.js (the most-downloaded Node.js framework), meaning it is transitively present in a large fraction of all Node.js production deployments worldwide. npm download counts are publicly verifiable and consistently in the hundreds of millions per month range. Direct use by framework authors is well-documented across the ecosystem.

Code analysis
Architecture

Appears to be a single-purpose TypeScript library exposing a small, composable API surface: parse (string → TokenData), pathToRegexp (path → RegExp + keys), match (path → match function), compile (path → path-builder function), and stringify (TokenData → string). The TokenData intermediate representation likely enables advanced use cases like custom path formats. Architecture appears deliberately minimal and dependency-light.

Tests

Build coverage badge is referenced in the README, suggesting automated coverage reporting is in place. Specific coverage percentage is not documented in the README excerpt.

Maintenance

Last push was 2026-06-01, approximately 23 days before the evaluation date — this is actively maintained. Given its age and stability, low commit frequency is expected and appropriate rather than concerning. The README references error improvements and breaking changes from past releases, indicating ongoing intentional stewardship.

Honest verdict

ADOPT IF: you are building a router, framework, or any system requiring structured URL path matching with named parameters in Node.js — this is the established, battle-tested choice. AVOID IF: you are targeting environments where the native URLPattern API is available and sufficient, or if you need query string or fragment matching (explicitly out of scope per README). MONITOR IF: you are building for edge runtimes or Deno where native URL APIs are maturing and may reduce dependency on this library over time.

Independent dimensions

Mainstream potential

4/10

Technical importance

8/10

Adoption evidence

9/10

Risks
  • Breaking changes between major versions (the README explicitly notes that ambiguous paths that previously worked now throw errors), which can cause unexpected failures when upgrading transitive dependencies.
  • The native URLPattern Web API is gaining traction in modern runtimes (browsers, Deno, Cloudflare Workers) and could reduce demand for this library in non-Node.js environments over a 2-5 year horizon.
  • As a transitive dependency of Express.js, its version may be pinned by upstream frameworks independently of your own upgrade path, leading to version conflicts in complex dependency trees.
  • Narrow scope by design — it explicitly does not handle query strings, fragments, or unordered data, which can surprise developers expecting a full URL parsing solution.
  • Low direct star growth suggests limited new direct adoption; future relevance likely depends on continued dominance of Express.js and Koa in the Node.js ecosystem.
Prediction

Likely to remain a stable, low-churn infrastructure component for as long as Express.js remains dominant in Node.js. Gradual displacement possible in newer runtimes as native URL APIs mature, but no near-term risk of obsolescence.

0 found this helpful

Newsletter

Get analyses like this every Monday

Free weekly digest of the most interesting open-source discoveries.

Languages

TypeScript
100%

Information

Language
TypeScript
License
MIT
Last updated
2w ago
Created
170mo ago
Analyzed with
anthropic/claude-haiku-4-5

Stars over time

Loading…

Contributors over time

Top 100 contributors only — repos with more will plateau at 100.

Loading…

Similar repos

unjs

unjs/magic-regexp

magic-regexp is a TypeScript library that provides a type-safe, readable...

4.3k TypeScript Dev Tools
expressjs

expressjs/cookie-parser

cookie-parser is a lightweight Express.js middleware that parses HTTP Cookie...

2k JavaScript Web Dev
expressjs

expressjs/body-parser

body-parser is the canonical Node.js middleware for parsing incoming HTTP...

5.5k JavaScript Web Dev
express-validator

express-validator/express-validator

express-validator is an Express.js middleware that integrates validator.js for...

6.2k TypeScript Web Dev
gskinner

gskinner/regexr

RegExr is an interactive web-based tool for learning, building, and testing...

10.3k JavaScript Dev Tools
vs. alternatives
regexpath / custom regex

Hand-rolled regex solutions lack named parameter extraction, optional groups, and the compile/reverse capability. path-to-regexp provides a tested, specification-level abstraction that manual regex cannot easily replicate.

URLPattern (Web Platform API)

URLPattern is a native browser/Deno API with similar goals but different syntax and no compile/reverse function. path-to-regexp has broader Node.js compatibility and a richer API surface, though URLPattern may reduce the need for this library in future runtimes.

qs (ljharb/qs)

Solves a complementary problem (query string parsing), not a competing one. Both are often used together in routing contexts.

trouter

Trouter is a lightweight router that internalizes its own path matching rather than delegating to path-to-regexp. Suitable for simple cases but lacks the API depth for framework-level use.

express-validator

Operates at a different layer (input validation after routing), not a routing primitive. Not a true competitor but often co-deployed in Express apps.