AUTOESCAPE / REGEX

Regex Escape

Escape pattern symbols so JavaScript regexes match your text literally.

AE—01 / ESCAPE WORKBENCHLocal processing

HTML escape / unescape

Turn reserved characters into HTML entities, or bring them back.

Escapes &, <, >, double and single quotes.
01 / SOURCE
0 characters · 0 bytes300k limit
02 / OUTPUT
0 characters · 0 bytesRead-only

Ready when you are. Conversion happens as you type.

Regex: find exactly what you typed.

Regular expressions give punctuation special jobs. A dot can match almost any character. Brackets can define a character class. Parentheses create a group. That is useful when you want a pattern—and frustrating when you only want to find a filename, price or message literally.

Regex Escape adds a backslash before the JavaScript regex metacharacters in your input. It also escapes the forward slash so the output can be used with the slash delimiter of a JavaScript regex literal.

BEFORE / INPUT
invoice.v2 (final) [paid] + $19.99
AFTER / OUTPUT
invoice\.v2 \(final\) \[paid\] \+ \$19\.99

Where this helps

  • Building a search pattern from an exact filename.
  • Matching a phrase that contains parentheses or brackets.
  • Looking for a price containing a dollar sign and a decimal point.
  • Preparing user-provided literal text before constructing a JavaScript regex pattern.

The result is not automatically anchored. If you want to match an entire string rather than find a literal substring, your application may need anchors such as ^ and $. Flags, input size and the rest of the pattern still need deliberate handling.

Pattern syntax is not string syntax

If you paste a regex pattern into a JavaScript quoted string, you have two layers to think about: regex escaping and JavaScript string escaping. A backslash that belongs to the pattern may itself need escaping in the source-code string. JSON String can help inspect a string representation, but it does not decide how your application should construct its regex.

Scope matters hereThis is a JavaScript regex pattern utility. It is not an escape tool for replacement strings, and it does not promise identical handling across every regex engine or special context such as a character class.

There is no Unescape mode. Removing backslashes from an arbitrary pattern could turn literal text back into operators and quietly change what it matches.

Need another format?

Return to the directory to choose a different tool.

All Tools →   Explore Guides →