🔎 Regex Escape Tool
Escape text so it can be used safely as a literal regex pattern. Runs in your browser.
Last updated: November 8, 2026 · By the BoltQuickTools team
Search for text that happens to contain regex symbols
If you drop a price, a file path or a user's search term into a regular expression, characters like ., $ and ( are treated as syntax and the pattern either fails or matches the wrong thing. Backslash-escaping them makes the engine read your text literally.
Using it
Paste into Text to Escape. Escaped Regex updates as you type, and the Escape button does the same thing on demand. Copy Regex takes the result, Load Sample fills in an example, and Clear empties both boxes.
Examples from the tool
| Text to Escape | Escaped Regex |
|---|---|
price: $19.99 (sale ends Friday) | price: \$19\.99 \(sale ends Friday\) |
C:\temp\*.log | C:\\temp\\\*\.log |
a/b-c [x] | a/b-c \[x\] |
Exactly these characters get a backslash: . * + ? ^ $ { } ( ) | [ ] \. Everything else, including line breaks, passes through unchanged. The status line counts the input, so the first example reads "Escaped 32 characters".
Where the output needs more work
- Forward slashes are left alone. That is correct for
new RegExp(text), but inside a JavaScript literal such as/a\/b/you must escape them yourself. - Hyphens are left alone, so do not paste the result inside a character class like
[...], where-can form a range. - A string literal needs its own escaping. To put the result in a JSON or JavaScript string, double each backslash again.
- Basic grep and sed read it differently. In POSIX basic mode
\(starts a group, so an escaped parenthesis does the opposite of what you want. Usegrep -E, orgrep -Fand skip escaping entirely.
Short answers
Does it work outside JavaScript?
The escaped characters are metacharacters in Python, PCRE, Java and .NET too, so the output generally works there. Python users can call re.escape in code instead.
Should I use this for a replacement string?
No. It only handles the pattern side. In a JavaScript replacement it is $ that matters, and a backslash has no special effect there.
How do I confirm the pattern matches?
Paste it into the regex tester with a sample of your data. For the rest of the syntax, see the regex cheatsheet.