Turn literal text into a safe regex pattern: a.b becomes a\.b, copy the ready /…/ form, reverse it too, all in your browser
- Runs locally
- Category Developer & DevOps
- Best for Formatting, validating, shrinking, or inspecting code-adjacent text.
Escapes . * + ? ^ $ { } ( ) | [ ] \ — the metacharacters shared by JavaScript and PCRE.
/price: \$9\.99 \(a\.b\)/
What this tool does
Regex escape takes a plain string and backslash-escapes every regex metacharacter so the pattern matches the text literally instead of acting as a wildcard. Paste "price: $9.99 (USD)" and you get "price: \$9\.99 \(USD\)" — the dot, dollar sign and parentheses are now treated as ordinary characters, not "any char", "end of line" or a capture group. It escapes the full set shared by JavaScript and PCRE: . * + ? ^ $ { } ( ) | [ ] and the backslash itself, with an optional switch for the forward slash when you write your regex as a /literal/ in JS source. The tool shows a ready-to-paste /pattern/ form with one-click copy, and a reverse mode that strips the backslashes to recover the original text. Everything runs as plain JavaScript in your tab, nothing is uploaded, and the input round-trips through the URL so a shared link reopens the exact same escaped pattern.
Tool details
- Input
- Text + Structured content
- The page exposes text boxes, numeric controls, file pickers, or structured inputs depending on the tool.
- Output
- Live result + Copy
- The result area focuses on usable output, with copy, download, or preview actions when supported.
- Privacy
- Browser-side processing
- The main tool logic does not call an external API, so inputs normally stay in the current tab.
- Save / share
- Shareable URL state
- Key settings are encoded in the URL so another person can reopen the same setup.
- Performance budget
- Initial JS <= 9 KB
- No WASM budget is declared, keeping the tool quick to open on mobile.
- Best fit
- Developer & DevOps · Developer
- Category and role tags drive related tools, internal links, and quick fit checks.
How to use
-
1. Input
Paste or drop your content into the tool panel.
-
2. Process
Click the button. All processing is local in your browser.
-
3. Copy / Download
Copy the result or download to disk in one click.
How Regex Escape fits into your work
Use it in the small gaps between coding, reviewing, debugging, and shipping.
Developer jobs
- Formatting, validating, shrinking, or inspecting code-adjacent text.
- Preparing snippets for documentation, tickets, commits, or handoff.
- Checking a small payload quickly without switching tools.
Developer checks
- Run irreversible transforms like minify or obfuscate on a copy.
- Keep secrets out of pasted snippets unless the tool explicitly stays local.
- Use your normal tests or linter before shipping transformed code.
Good next steps
These links move the current task into a more complete workflow.
- 1 Regex Tester Test JavaScript regex live — match highlighting, group capture, replace preview, flag toggles — browser-only Open
- 2 String Escape / Unescape Escape & unescape strings for JSON, JS, Java, C, SQL, Shell, HTML, CSV & regex — both directions — browser-only Open
- 3 Find and Replace Text Batch find-and-replace on big text — regex, $1 capture groups, whole-word, case toggle, multiple chained rules — runs entirely in your browser Open
Real-world use cases
Build a literal search out of user input
You let users type a search term and you feed it into a RegExp to highlight matches. If someone searches for "C++" or "a.b", the raw regex blows up or matches the wrong thing — the plus is a quantifier, the dot is a wildcard. Escape the input first and the search matches exactly what they typed. This is the canonical use of re.escape / RegExp.escape, and the tool lets you see the escaped form before you wire it in.
Match a version number or domain literally
Filtering logs for "1.0.3" or "api.stripe.com"? Unescaped, those dots are wildcards, so 1.0.3 also matches 10503 and api.stripe.com matches apiXstripeYcom. Paste the string here, copy the escaped /1\.0\.3/, and your grep or log query stops catching false positives that the dots quietly let through.
Hand-tune a generated pattern, then reverse it
You inherited a regex like a\.b\*c and want to know what literal it was built from. Drop it into unescape mode and read back a.b*c. Tweak the plain text, flip to escape, and you have a clean rebuilt pattern — no counting backslashes by hand and no guessing which ones were real regex tokens versus escaped literals.
Teach or document how escaping works
Writing a tutorial or answering a Stack Overflow question about why a.b matches too much? Share a link with the input pre-filled — the URL carries the literal and options — and the reader lands on the exact before/after, including the ready /a\.b/ form. It is a faster explanation than a paragraph, and they can edit it live.
Common pitfalls
Escaping the result a second time. If your language already has re.escape or RegExp.escape, do not also paste the output here — double escaping turns a\.b into a\\.b, which now matches a backslash followed by any char. Escape once, at the point where literal text enters the pattern.
Forgetting that the backslash itself needs escaping. A literal backslash in your text must become \\ in the pattern, or it pairs with the next character and changes its meaning. The tool handles this, but hand-written escapers often miss it and produce patterns that silently match the wrong thing.
Escaping the forward slash when you do not need to. The slash is only special as a JavaScript /literal/ delimiter. If you build the regex from a string, escaping the slash adds a stray backslash that some engines reject or treat as literal. Leave the slash option off unless you are writing the pattern between /…/ delimiters.
Privacy
The text you paste, the escaping, the reverse pass and the /…/ form are all computed by plain JavaScript inside your browser tab. Nothing is sent to a server and nothing is logged. The one thing to know: the input is encoded into the page URL so that a shared link reopens the same escaped pattern, which means a link you paste into chat records that text in the recipient server's access log. The literal text here is usually harmless, but if it contains anything sensitive, use the copy button and paste the result rather than sharing the URL.
FAQ
Tool combos
Folks in your role tend to reach for these alongside this tool.
- 555 Timer Calculator Astable f = 1.44/((R1+2R2)C) + monostable t = 1.1RC — pick R1, R2, C in Ω/kΩ and µF/nF, read frequency, duty cycle and pulse width — browser-only
- Add Line Numbers Number every line of pasted text — set start, step and separator, zero-pad to align, skip blanks, or strip numbers back off — browser-only
- AES Text Encryptor Encrypt & decrypt text with a password — AES-256-GCM + PBKDF2 via WebCrypto — 100% in your browser, nothing uploaded
- Affine Cipher Encoder & Decoder Encrypt and decrypt the ax+b affine cipher with live modular-inverse check, browser-only