Regex Escape Tool
Escape special characters so text matches literally in a regex — output for JavaScript, PHP or Python, plus unescape.
Tool input is processed locally in your browser and is not submitted to CodeNimbleTools. Avoid pasting production secrets into any device or website you do not fully trust.
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.
Worked example
Example input
price ($10.00)
Expected output
price \(\$10\.00\)
Edge cases to check
- Escaping rules vary by regex flavor and character-class context.
- Flags and delimiters are language-specific.
Known limitations
Escaping literal text does not validate the surrounding regular expression or protect against catastrophic backtracking elsewhere.
How this tool was reviewed
Reviewed with punctuation, brackets, slashes and common metacharacters.
Standards and technical references
See the site-wide testing methodology for fixture categories, privacy checks and correction policy.
Frequently asked questions
Which characters are escaped?
What do the language modes add?
Does escaping change matching behavior?
Privacy
Tool input is processed locally in your browser and is not submitted to CodeNimbleTools. Avoid pasting production secrets into any device or website you do not fully trust.