Glob to Regex Converter
Convert glob patterns to regular expressions and vice versa. Test against strings, see explanations of each component. Supports **, *, ?, {a,b}, and more.
Your data never leaves your browser
Available via MCP
Enter a glob pattern and click Convert
How to Use
- Select conversion direction: Glob → Regex or Regex → Glob.
- Enter your pattern (e.g.,
src/**/*.ts). - Optionally enter a test string to verify matching.
- Click Convert to see the equivalent regex and an explanation.
Glob Pattern Reference
*— matches any characters except path separator (/)**— matches any characters including path separators (any depth)?— matches exactly one character (not/){a,b,c}— matches any of the alternatives[abc]— matches any character in the set[!abc]— matches any character NOT in the set
Common Glob Patterns
src/**/*.ts— all TypeScript files under src/*.{js,jsx,ts,tsx}— all JS/TS files in current directory!node_modules/**— exclude node_modules (in .gitignore)**/*.test.*— all test files at any depth
Related Tools
Test regex patterns with the Regex Tester. Understand regex syntax with the Regex Explainer. Generate .gitignore files with the .gitignore Generator. Build git commands with the Git Command Builder.
Frequently Asked Questions
- What is a glob pattern?
- A glob pattern is a simplified pattern syntax for matching file paths. Common in .gitignore, shell commands, and build tools. "*" matches any characters except "/", "**" matches any characters including "/", "?" matches a single character, and "{a,b}" matches alternatives.
- How is a glob different from regex?
- Globs are simpler and path-oriented: "*" means "any filename characters" (not including /), while in regex ".*" means "any characters." Globs are used for file matching; regex is used for general text pattern matching.
- Can I convert regex back to glob?
- Yes, but regex-to-glob is a best-effort conversion. Simple patterns convert well, but complex regex features (lookahead, backreferences, non-greedy quantifiers) have no glob equivalent.
- What does ** mean in a glob?
- ** (double star) matches any number of directories, including zero. "src/**/*.ts" matches "src/file.ts", "src/a/file.ts", and "src/a/b/c/file.ts".
Use this tool from AI agents.
The CodeTidy MCP Server lets Claude, Cursor, and other AI agents
use this tool and 46 others directly. One command: npx @codetidy/mcp