How to Test and Debug Glob Pattern Matching with an Online Glob Tester
Updated
Glob pattern matching is the wildcard syntax used to match filesystem paths, and you can test it without installing anything by pasting a pattern into an online glob tester such as globster.xyz. Type your pattern into the input field and every matched file is highlighted in blue in the tree directory structure, which makes it easy to see why a pattern over-matches, under-matches, or fails entirely. This works best when you already have a rough idea of the files you expect to match and want to confirm the syntax before putting it into a .gitignore, a build script, or a shell command.
Glob vs. regular expressions
Glob and regex both do pattern matching, but they solve different problems.
| Glob | Regular expression | |
|---|---|---|
| Primary use | Matching files and paths in a filesystem | Matching arbitrary text |
| Syntax complexity | Small, limited set of wildcards | Large, expressive grammar |
| Typical tools | Shell commands, .gitignore, build tools |
Search, validation, parsing |
| Example | *.jpg matches every JPEG in a folder |
.*\.jpg$ matches the same strings in text |
The classic illustration is a shell command like cp *.jpg ./thumbnails, which copies every file with a .jpg extension into the thumbnails folder. Here *.jpg is the glob pattern, and it matches all files in the current working directory ending in .jpg. Think of glob as pattern matching for the filesystem rather than for text.
Globbing originated in Unix and is now used widely — the .gitignore file in Git is one common example, where patterns exclude certain files and folders from version control.
Core wildcard syntax
Syntax depends on the implementation. The tester on globster.xyz evaluates patterns with the minimatch JavaScript library (version 3.0.4), which supports basic wildcards, brace expansion, extended glob matching, and globstar.
| Pattern | Meaning |
|---|---|
? |
Matches a single character |
* |
Matches any string |
/ |
Path separator |
** |
Globstar: matches all files and zero or more directories and subdirectories |
{a,b} |
Brace expansion: expands into multiple patterns |
?(a|b) |
Extglob: matches zero or one occurrence |
*(a|b) |
Extglob: matches zero or more occurrences |
+(a|b) |
Extglob: matches one or more occurrences |
@(a|b) |
Extglob: matches exactly one occurrence |
!(a|b) |
Extglob: matches anything except the listed patterns |
Globstar ** and its main limitation
** matches all files plus zero or more directories and subdirectories. If it is followed by a /, it matches only directories and subdirectories.
The catch that trips people up: to behave that way, ** must be the only thing inside the path part. A pattern like /myapp/**.js will not work as a recursive match, because ** is not alone in its path segment.
Brace expansion
An expression inside curly braces expands into multiple patterns. For example, **/*.{b,c} expands into **/*.b and **/*.c, and the final result is the union of checking both patterns. Brace sets with a range work too: **/{a..c} expands into **/a, **/b, and **/c.
Step-by-step: testing a glob pattern
- Decide what should match. Write down the exact files you expect, for example "all
.jsfiles in any subdirectory exceptnode_modules." - Enter the pattern into the input field of the glob tester.
- Read the highlighted results. Matched files appear in blue in the tree directory structure. Compare them against your expected list.
- Adjust and repeat. If files you expected are not highlighted, the pattern is too narrow; if extra files are highlighted, it is too broad.
- Copy the verified pattern into your
.gitignore, build config, or shell command.
Verification and common sticking points
- Over-matching:
*matches any string, including across many characters you did not intend. Narrow it with a more specific prefix or extension. - Recursion not working: check whether
**is alone in its path segment./myapp/**.jsis a frequent offender. - Brace expansion surprises: remember the result is a union, so
**/*.{b,c}will match both sets, not an intersection. - Implementation differences: minimatch is not the only glob library. JavaScript also has micromatch and extglob, Python has the
globmodule, and Linux shells have their ownglob. A pattern that works in one may not behave identically in another, so test against the tool that will actually run your pattern.
When to use an online glob tester
Use globster.xyz when you want to debug a glob that is not working, or to experiment and learn from the provided examples without setting up a project. It is a fast feedback loop for syntax questions: type, observe the highlighted matches, and correct. For patterns destined for a specific language or tool, confirm the behavior against that tool's own glob implementation before relying on it in production.