String Escape / Unescape
Escape and unescape text for HTML, URL, JSON, Regex, Base64, and C-string. Live preview, bulk mode, one-click copy.
About this tool
The String Escape / Unescape tool converts raw text into the escaped form required by a target context — and back. Switch between HTML entities, URL encoding (component or whole-URI), JSON string, regular expression, Base64, and C-style string escapes, then toggle between Escape and Unescape with one click. Output updates live as you type, so you can see exactly which characters get transformed.
Typical use: pasting a string that contains quotes, ampersands, angle brackets, or backslashes into a template, query string, JSON file, or regex pattern without breaking it. The Swap button feeds the output back as input and flips the direction, so you can round-trip a value and confirm it matches.
Examples (HTML escape):
Tom & "Jerry"→Tom & "Jerry"<script>alert(1)</script>→<script>alert(1)</script>
Examples (Regex escape):
price: $9.99*→price: \$9\.99\*
FAQ
What is the difference between "URL (component)" and "URL (whole)"? ›
URL (component) uses encodeURIComponent, which encodes every character that is not safe inside a query parameter — including /, ?, =, and &. Use it for a single query value. URL (whole) uses encodeURI, which leaves those structural characters intact so you can encode an entire URL in one pass.
Why does JSON mode strip the surrounding quotes? ›
The tool escapes the body of a JSON string — the part that sits between the quotes. If you want the full quoted form, wrap the output in double quotes yourself, or paste the quoted input back and use Unescape to verify it parses.
What does "C-string" mode do? ›
It applies the backslash escapes used in C, Java, JavaScript, and Python string literals: newline becomes \n, tab becomes \t, the backslash itself becomes \\, the double quote becomes \", and any other control character under U+0020 becomes \uXXXX. This is handy when you need to embed a multiline block of text into a source-file string.
Does the Regex mode escape everything I need for a literal match? ›
It escapes all standard regex metacharacters: . * + ? ^ $ { } ( ) | [ ] \ /. Some regex flavours add extra meaning to characters like # or -, but those are context-sensitive and left untouched. For a plain literal search this is sufficient.
How is HTML escaping here different from the HTML Entity Encoder? ›
HTML mode here escapes the five primary HTML-sensitive characters (<, >, &, ", ') — enough to safely paste user text into an HTML document. The dedicated <a href="/html-entity">HTML Entity Encoder</a> goes deeper: it supports the full set of named entities (©, —, ), decimal references (<), and hexadecimal references (<). Use this when you need a quick multi-format escape; use the Entity Encoder when you need complete HTML entity coverage.