Skip to content
TabKiwiTabKiwi

Regex Escape

Escape special characters so any text matches literally inside a regular expression.

DeveloperRuns in your browser. Your files never leave this device.
Loading tool…

About this tool

Characters such as . * + ? ( ) [ ] { } | ^ $ and backslash have special meaning in a regular expression. This tool puts a backslash in front of each one so your text, a file path, a price or a URL, is matched exactly as written. It can also wrap the result as a /…/ literal, produce a quoted string for new RegExp(), or turn a list of lines into one alternation.

How to use Regex Escape

  1. Paste the literal text.
  2. Choose how you want the output formatted.
  3. Copy the escaped pattern into your code.

Frequently asked questions

Why does a string for new RegExp() have double backslashes?

The string literal consumes one level of backslashes, so \. in a pattern must be written "\\." inside quotes.

Is the output safe with the u flag?

Yes. Only characters that are valid to escape in Unicode mode are escaped, so the pattern works with or without u.

More Developer tools

View all 91 →