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.

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

  1. Paste the text you want to match literally.
  2. Pick a target: plain pattern, JavaScript, PHP or Python.
  3. Optionally escape forward slashes for /.../ literals.
  4. 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.

Last reviewed: September 3, 2026 · Maintainer: William

Standards and technical references

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

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.