Escape and unescape
Escape or unescape a string for JSON, HTML, URL, JavaScript, XML or a CSV field. Check the round trip with one click.
Text
Options
Result
What it does
The escape and unescape tool turns a text into a safe string for six formats and back again. Pick JSON, HTML, URL, JavaScript, XML or a CSV field, paste your text and copy the result. JSON and JavaScript get backslash escapes for quotes, line breaks and control characters. HTML and XML get entities such as & and <. URL uses percent encoding, and CSV wraps a field in quotes and doubles the quotes inside. You can write every non-ASCII character as an escape, and one click feeds the result back in the other direction so you can check the round trip. Everything runs in your browser.
How to use it
- 1Pick the format: JSON, HTML, URL, JavaScript, XML or CSV.
- 2Choose Escape or Unescape and paste your text.
- 3Copy the result, or press the swap button to test the round trip.
Common uses
- Put a text with quotes and line breaks safely into a JSON string.
- Show code or user input on a web page without it being read as HTML.
- Encode a value for a URL query string or decode one from a log.
- Read a string copied from a log or a source file that is full of backslashes.
- Prepare a CSV field that contains commas, quotes or line breaks.
- Write non-ASCII text as \u escapes for a file that must stay ASCII.
Questions
What does escaping do?
It replaces characters that have a special meaning in a format (a quote in JSON, a less-than sign in HTML) with a safe form, so the text is read as plain text.
Which formats are supported?
JSON, HTML, URL (percent encoding of a component), JavaScript strings, XML and a single CSV field.
What is the difference between HTML and XML escaping?
HTML knows many named entities such as © and €. XML has only five: &, <, >, " and '. Both read numeric entities like A.
Why does unescape say my text is not valid?
A broken escape cannot be read: a lone backslash, a short \u code, or a percent sign that is not followed by two hex digits. The message names the format so you can fix the text.
Can I escape every non-ASCII character?
Yes. Turn on "Write non-ASCII characters as escapes" for JSON, JavaScript, HTML and XML. Letters like the German umlauts then become \u00E4 or ä.
Does the URL mode encode a whole address?
It encodes a component, like a query value. Slashes, question marks and equals signs are encoded too. Use the URL parser for a complete address.
Is my text uploaded?
No. The conversion runs in your browser and nothing is sent anywhere.