How to use this tool
- Paste or type the string you want to use as a literal regex pattern.
- Click Escape to add backslashes before special characters.
- Copy the escaped result and paste it into your regex or code.
About Regex Escape
This tool escapes characters that have special meaning in regex (e.g. . * + ? [ ] ( ) | \), so you can safely match user input or file paths as literal text. It is useful when building dynamic patterns from untrusted strings.
Common use cases
- Escaping user search input before using it in a regex pattern
- Converting file paths or URLs into literal match patterns
- Preparing strings for RegExp constructors or replace operations
FAQ
- What does regex escaping do?
- It adds backslashes before characters that have special meaning in regex (like . * + ? [ ] ( ) | \), so the pattern matches those characters literally instead of as regex metacharacters.
- Does this tool send my text anywhere?
- No, escaping runs entirely in your browser. Your input never leaves your device.
- Will the escaped output work in all regex engines?
- The output follows JavaScript regex escaping rules. Other engines (PCRE, Python, etc.) may have slightly different special character sets, so test in your target environment.
- When should I escape vs. use a regex directly?
- Escape when your pattern comes from user input, config, or file paths. Use raw regex when you control the pattern and want metacharacters like . or * to have their special meaning.