Skip to content
gohacks.dev
APIs

Route Pattern Tester

Test URL paths against route patterns written in Laravel, Express or Next.js syntax, and see which route matches each path and the parameters it captures.

Free · No sign-up · Your inputs stay in your browser

Input

Test URL paths against route patterns

Output

6 of 7 matched

PathRouteParameters
/users/42/users/{user}user=42
/users/42/posts/users/{user}/posts/{post?}user=42, post=(absent)
/users/42/posts/hello-world/users/{user}/posts/{post?}user=42, post=hello-world
/blog/redis-cache/blog/:slugslug=redis-cache
/docs/guides/install/linux/docs/[...path]path=guides/install/linux
/files/a/b.txt/files/*wildcard=a/b.txt
/nopeno match (404)-

The first route that matches wins, which is how Laravel and Express resolve them: register /users/create before /users/{user}, or the literal path is captured as a parameter. A parameter matches one segment; catch-all segments match the rest of the path. Laravel's ->where() constraints and Next's static-before-dynamic priority are not modelled.

Runs in this browser. Nothing you paste is sent to a server.

First match wins

Laravel and Express try routes in registration order and stop at the first that matches. Register /users/{user} before /users/create and the literal path is captured as a user id; the fix is ordering or a constraint such as whereNumber. Laravel's route parameters documentation covers constraints and optional parameters.

Next.js is different

The App Router does not use registration order: a static segment always beats a dynamic one, and a dynamic segment beats a catch-all, whatever the file layout. Optional catch-alls also match the parent path.

Share

Frequently asked questions

Does a route parameter match a slash?
No. A parameter matches one path segment. Use a catch-all ([...slug] in Next.js, a where('path', '.*') constraint in Laravel) to capture several segments.
Are query strings part of route matching?
No. Routes match the path only; the query string is read separately from the request.
Is what I paste sent anywhere?
No. The tool runs entirely in your browser with JavaScript. Nothing you type or paste is sent to our server or stored.

Keep planning

Similar tools