JSON Escape / Unescape
Escape text for JSON strings or decode escaped content.
Your result will appear here…
How to use JSON Escape / Unescape
- Choose Escape for plain text or Unescape for escaped string contents.
- Paste the value without surrounding quotation marks.
- Run the conversion and copy the result into your JSON string or editor.
Example
Input / settings:
Line one Line "two"
Output:
Line one\nLine \"two\"
Newline became \n and each double quote gained a backslash. The result has no surrounding quotation marks.
When to use
- Embed a multi-line message or file path in a JSON field.
- Read an escaped log line or API payload as plain text.
- Prepare a JSON document to be stored as a string inside another JSON document.
Overview
JSON Escape turns text into the contents of a JSON string. A backslash and a double quote are prefixed with a backslash, newline, carriage return, tab, backspace and form feed become \n, \r, \t, \b and \f, and any other control character below U+0020 becomes a \uXXXX sequence. The tool does not add the surrounding quotation marks. Unescape reverses the process.
Supported input
Any text to escape, or the contents of a JSON string (without surrounding quotation marks) to unescape.
Output details
Escaped text without surrounding quotation marks, or the decoded text.
Common mistakes
- The output has no surrounding double quotes. Add them yourself when pasting it into a JSON document.
- Unescape expects the inside of a string written the way JSON writes it. Surrounding quotation marks, a double quote without a backslash, and raw line breaks or tabs (instead of \n and \t) are all rejected with an error.
- Non-ASCII characters and the forward slash are not escaped: café / 日本語 is returned unchanged. That is valid JSON, because RFC 8259 requires escaping only the quotation mark, the backslash and control characters U+0000 to U+001F.
- Unescape accepts JSON escapes only. \/ and \u00e9 decode, but \x41 is rejected because JSON has no \x escape, and so is a lone backslash at the end of the text.
Practical tips
- Paste the finished document into JSON Formatter to confirm that it parses.
- In code, build JSON with JSON.stringify instead of escaping by hand. Use this tool for one-off values.
Privacy and security
This tool runs entirely in your browser. Your input is never uploaded to our servers. Escaping and unescaping run locally in your browser. Text escaped for JSON is still untrusted data: escaping does not make it safe to insert into HTML, so use HTML Escape for that purpose.
References
Frequently asked questions
Which characters does JSON Escape change?
The backslash, the double quote, and control characters below U+0020. Letters, digits, accented characters and the forward slash are left alone.
Why does Unescape report an error?
The text contains something JSON does not allow inside a string, such as an unescaped double quote, a raw line break or tab, an unknown escape like \x41, or a trailing backslash.
Can I escape an entire JSON document?
Yes. Quotes and backslashes in the document are escaped, giving text you can store inside another JSON string. To check or reformat the document itself, use JSON Formatter.