Glob to Regex Converter

Convert a glob pattern to a JavaScript regular expression in your browser and test it against real paths. Your patterns stay on your device.

Your glob pattern and the sample paths you test are converted locally in your browser and are never uploaded.

Need to debug the result? Open the Regex Tester.

About Glob to Regex

This glob to regex converter turns a shell-style wildcard pattern into an equivalent JavaScript regular expression you can drop straight into code. Type a glob such as *.js, **/*.ts, src/** or file-{a,b}.txt and the tool builds the regex source plus flags, escaping literal characters like dots and parentheses so they match exactly. Toggle globstar so ** crosses path separators, brace expansion for {a,b,c} alternation, full-string anchoring with ^ and $, and a case-insensitive flag. A live tester runs your regex against a list of sample paths, marking each match in green and each miss in red, and a legend explains every translated token. Everything runs in your browser, so the patterns and paths you enter stay on your device.

Features

How to use the Glob to Regex

  1. Type or paste a glob pattern such as **/*.ts into the pattern box.
  2. Switch globstar, anchoring, brace expansion and case-insensitivity on or off.
  3. Read the generated regex source and flags, and review the token legend.
  4. Enter sample paths in the tester, one per line, to see which match.
  5. Click Copy regex to grab the /pattern/flags literal for your code.

Example

Input

src/**/*.{ts,tsx}

Output

/^src/(?:.*/)?[^/]*\.(?:ts|tsx)$/

Globstar lets src/**/ span nested folders while *.{ts,tsx} stays at the leaf.

Common errors & troubleshooting

Frequently asked questions

What does ** mean in a glob pattern?
** is the globstar. With the globstar option on it matches across path separators, so src/**/*.ts reaches files in any nested folder, whereas a single * stops at the next /.
How are glob character classes converted to regex?
[abc] maps straight to a regex character class, ranges like [0-9] are kept intact, and a negated glob class written [!abc] is converted to [^abc] so it matches any character not listed.
Why does the converter escape dots and other characters?
Characters such as . + ( ) | are literal in a glob but special in a regex. The tool escapes them to \. \+ and so on, so the resulting regex matches those characters exactly instead of as operators.
Does it support brace expansion like {a,b,c}?
Yes. With brace expansion enabled, file-{a,b}.txt becomes an alternation that matches file-a.txt or file-b.txt, and you can even nest globs inside braces, such as {*.js,*.ts}.
Can I match a substring instead of the whole path?
Turn off full-string anchoring. Anchored patterns are wrapped in ^…$ so the entire string must match; without anchoring the regex can match anywhere inside a longer string.
Is my glob pattern sent to a server?
No. The glob to regex conversion and the live tester both run entirely in your browser, so the patterns and sample paths you type are processed locally and stay on your device.

Related tools

All ArrayKit tools