Skip to content

Glob to regex converter

Turn glob patterns like *.js or **/*.test.ts into the matching regular expression.

Input
Test paths (optional)
Output

Glob to regex converter

Paste one or more glob patterns and this tool builds the equivalent regular expression for each one, ready to drop into a script, a config file or a language that only understands regex. Pattern conversion also runs the other way: switch the direction to turn a simple regular expression back into a glob-style pattern. Every line of the input is treated as its own pattern, so you can convert a whole batch — a build ignore list, a set of route matchers, a list of file filters — in one pass.

The glob style option adjusts how a pattern is read: shell treats it as a plain filename wildcard, .gitignore adds Git's own rule that a pattern with no slash in it matches at any folder depth while a pattern containing one is rooted to that location, and minimatch supports curly-brace alternation like *.{js,ts}. Toggle whether a double star (**) is allowed to cross directory separators or behaves like a single star, whether a leading wildcard should match dotfiles such as .env, case sensitivity, and whether the result is anchored with ^ and $ to match the whole string rather than just part of it. Character classes such as [abc] and [!0-9] are also converted.

Paste a list of paths into the second field to see, live, which of your patterns match which paths — useful for checking a .gitignore rule or a route pattern before you commit to it. The output stays in the order patterns were entered, and both CRLF and LF line endings are accepted.

Everything runs locally in your browser: patterns and test paths never leave your device. When done, copy the expressions, download a .txt file, or send the output back into the input to refine it further.

FAQ

What does a double star (**) match?
With "Double star crosses slashes" on, ** matches any number of characters including path separators, so a/**/z matches a/b/c/z. Turn it off and ** behaves like a single star, stopping at the next /.
How does the .gitignore style differ from a plain shell glob?
Following Git's own rule, a .gitignore pattern with no slash (like *.log) matches at any depth in the tree, while a pattern containing a slash (like build/*.log) is rooted to that exact location.
Can it convert a regex back into a glob?
Yes, switch Direction to "Regex → glob". This is a best-effort conversion aimed at simple patterns — it recognizes common building blocks like [^/]*, (?:a|b) and character classes, but an arbitrarily complex regular expression may not have a clean glob equivalent.
Does the star match hidden files like .env?
Not by default: a wildcard at the start of a path segment skips a leading dot, matching typical shell and .gitignore behavior. Turn on "Wildcards match hidden (dot) files" to include them.
Is my text uploaded anywhere?
No. The conversion and path testing both run entirely in your browser — nothing you paste in ever leaves your device.