Free Regex Escape Tool
Turn any literal text into a safe regex pattern in one click. Dots, brackets, plus signs, and every other special character get properly escaped — so your pattern matches the exact text you typed instead of blowing up or matching the wrong thing.
Result
Test result
How to Use the Regex Escape
- Paste the literal text you want to match.
- Click Escape — every special character is backslash-escaped.
- Copy the safe pattern into your regex.
- Use Unescape to reverse the process on escaped text.
Features
Escaping covers the full regex metacharacter set — . * + ? ^ $ { } ( ) | [ ] \ — so the output matches your input literally in JavaScript, Python, Java, .NET, and PCRE. Unescape mode reverses the process, and a live test box lets you confirm the escaped pattern matches the original text before you use it.
Benefits & Use Cases
Developers safely embed user input, filenames, URLs, and version strings into larger patterns without regex-injection bugs; anyone building search-and-replace patterns avoids the classic “dot matches everything” mistake. It is the fastest way to turn “this exact string” into a correct pattern.
Tips
If you are matching user input inside a bigger pattern, always escape the input portion — unescaped input is a common source of ReDoS and logic bugs. Remember that inside a character class [...], fewer characters need escaping, but escaping them anyway is harmless.
Frequently Asked Questions
Why do I need to escape regex special characters?
Characters like . * + ? have special meaning in regex. To match them literally — a real dot in “file.txt” — they must be escaped with a backslash, or the pattern will match the wrong things or fail to compile.
Which characters get escaped?
The standard metacharacters: . * + ? ^ $ { } ( ) | [ ] and the backslash itself. These are the characters with special meaning in most regex flavors.
Does escaping work for all programming languages?
The output is valid for JavaScript, Python, Java, PHP, Ruby, Go, Rust, and .NET. Extremely exotic flavors may differ on edge cases, but literal escaping is consistent everywhere.
What is regex injection?
When unescaped user input is inserted into a pattern, a malicious user can craft input that changes what the pattern matches — or triggers catastrophic backtracking. Escaping user input prevents this.
Is my text uploaded anywhere?
No. Escaping runs entirely in your browser — your text never leaves your device.
Related Tools
Regex Tester
Test regular expressions live with NToolHub’s free tester. Match highlighting, groups, flags, clear errors — 100% private.
Open tool →Regex Generator
Build regex patterns visually with NToolHub’s free generator. Token builder, presets, plain-English explanation — no regex PhD needed.
Open tool →JavaScript Minifier
Minify JavaScript safely with NToolHub’s free minifier. String- and regex-aware compression with byte savings — 100% private in-browser.
Open tool →URL Encode
Percent-encode URLs and text instantly with NToolHub’s free tool. Component or full-URL mode, UTF-8 safe — private in-browser.
Open tool →