01What is Regex Escape Tool?
Say you want a regular expression that matches the text $9.99 (USD) exactly. Feed that straight into a regex and it breaks. The dot matches any character, the dollar sign anchors to the end of a line, and the parentheses open a capture group. Regex Escape Tool fixes this by putting a backslash in front of every character that has a special meaning, so the pattern matches your text literally. The tool escapes fourteen characters: . * + ? ^ $ { } ( ) | [ ] and the backslash itself. That is the same set used by the escapeRegExp helper on MDN's regular expressions guide. Internally it is a single replace call that prefixes each match with a backslash. Nothing else in your text changes. A worked example. Paste price: $9.99 (USD) in Escape mode and the output is price: \$9\.99 \(USD\). A label above the panels reports that 4 special characters were escaped. Pass that output to new RegExp() and it matches the original string and nothing else. Unescape mode goes the other way. It removes a backslash only when the next character is one of those same fourteen. So \d+\.\d+ becomes \d+.\d+, and the \d character classes survive. Escapes outside the set, such as \- or \/, are left alone as well. That makes it handy for cleaning an over-escaped pattern copied from a config file. Input and Output sit side by side, each with a live character count. Copy puts the result on your clipboard, and Reset clears the input. Built-in examples cover a Windows file path, a URL with a query string and a maths expression packed with brackets. Be aware of what it does not do. Hyphens and forward slashes are not escaped. A hyphen only matters inside a character class, and a slash only inside a /pattern/ literal, so you add those by hand when you need them. The output is regex text, not a string literal. If you paste it inside quotes in JavaScript, Java or JSON, double every backslash again. Basic POSIX grep and sed also read \( and \{ as operators, so use grep -E or sed -E there. The escaping happens in the page as you type, and your text stays on your computer.
Developers who build regular expressions from literal text, such as user search input, file paths or URLs, and need every metacharacter escaped correctly. The tool runs entirely in your browser, so your data never leaves your device.
02How to use Regex Escape Tool
- Choose Escape (literal → regex-safe) or Unescape (remove backslashes) in the Mode menu
- Paste your text into Input
- Read the result in Output, along with the count of special chars escaped in Escape mode
- Click Copy to take the result, or Reset to clear the input
03Worked examples
- Input:
Escape: price: $9.99 (USD) - Result:
price: \$9\.99 \(USD\) (4 special chars escaped) - Unescaped, the dot would match any character and the parentheses would form a group.
- Input:
Escape: [x] - Result:
\[x\] - Without escaping, [x] is a character class that matches only the letter x.
- Input:
Escape: C:\temp\*.log - Result:
C:\\temp\\\*\.log - Backslashes are doubled, and * and . are escaped too.
- Input:
Escape: https://example.com/api/v1/users?name=John+Doe&age=30 - Result:
https://example\.com/api/v1/users\?name=John\+Doe&age=30 (3 special chars escaped) - Slashes, = and & are not metacharacters, so they stay as they are.
- Input:
Escape: a-b/c - Result:
a-b/c (unchanged) - Hyphens and slashes are not in the escaped set.
- Input:
Unescape: \d+\.\d+ - Result:
\d+.\d+ - Backslashes are removed only before special characters, so \d is kept.
04Common use cases
- Turning a search box value into a safe new RegExp() pattern for a JavaScript filter, so input like a+b doesn't throw or misbehave
- Matching a literal URL with ? and + in its query string inside a log-parsing script
- Writing a grep -E or ripgrep pattern for a Windows path such as C:\temp\*.log
- Escaping a version string like 1.2.3 for a regex find-and-replace, so the dots don't match any character
- Cleaning an over-escaped pattern copied from a JSON config with Unescape, while keeping classes like \d intact
- Checking how many metacharacters a pasted string contains before using it in a pattern
05Tips
- Inside a JavaScript, Java or JSON string literal, every backslash in the output has to be doubled again. \. becomes "\\.".
- Forward slashes aren't escaped. Add \/ yourself if the result goes into a /pattern/ literal.
- If you drop escaped text inside [ ], escape any hyphen manually, since - forms a range there.
- Plain grep and sed use POSIX basic regex, where GNU versions treat \( \{ \| \+ and \? as operators. Use grep -E, grep -F or sed -E instead.
- Escaping user input before new RegExp() turns it into plain literal text, so a user can't slip in a pattern with nested quantifiers.
06Related concepts
regular expressions, metacharacters, escaping, RegExp constructor, literal matching.
Frequently Asked Questions
What is Regex Escape Tool?
Regex Escape Tool is a free, browser-based developer tool on AIDToolStack. Escape/unescape regex special characters It requires no installation or sign-up and works entirely in your browser.
Is Regex Escape Tool free to use?
Yes. No sign-up, no fees and no usage cap.
Does Regex Escape Tool store my data?
No. It runs in your browser; nothing is uploaded.