Regex Escape Tool
Escape special characters so text matches literally in a regex — output for JavaScript, PHP or Python, plus unescape.
This tool runs 100% in your browser. Your data is never uploaded, stored, or logged.
Escaped result
About this tool
Searching for price is $9.99 (each) with a regex fails hilariously unless every special character is escaped. This tool escapes all regex metacharacters — .*+?^${}()|[]\ — and can wrap the result as a ready literal for JavaScript, PHP (preg_quote) or Python (re.escape).
The unescape mode reverses it when you need the original text back.
How to use it
- Paste the text you want to match literally.
- Pick a target: plain pattern, JavaScript, PHP or Python.
- Optionally escape forward slashes for /.../ literals.
- Copy the escaped result or generated code snippet.
Useful ways to apply it
- Building a regex from user input safely.
- Searching logs for strings full of dots and brackets.
- Writing find-and-replace patterns in editors.
- Generating language-correct escaping without memorizing rules.
Frequently asked questions
Which characters are escaped?
The regex metacharacters . * + ? ^ $ { } ( ) | [ ] and backslash — plus / optionally, for regex literals delimited by slashes.
What do the language modes add?
They wrap the escaped text in correct string/regex syntax for that language and show the built-in equivalent (RegExp, preg_quote, re.escape) so you can use either.
Does escaping change matching behavior?
Escaped text matches itself exactly — nothing more. That's the point: any special meaning is neutralized.
Privacy
This tool runs 100% in your browser. Your data is never uploaded, stored, or logged.