JSON escape and unescape
Inside a JSON string, double quotes, backslashes and control characters such as newlines must be escaped with a backslash. Paste text to get a string you can drop between quotes in JSON, or paste an escaped string to get the original text back.
Escaped text (goes between the quotes)
Raj said \"ship it\"\nFolder: C:\\Projects\\Shop\n\tPrice: ₹250 — paid
- Characters escaped
- 7 of 63quotes ×2, backslashes ×2, line breaks ×2, tabs ×1
- Length
- 63 → 70 characters
How does JSON string escaping work?
RFC 8259, the JSON standard, says every Unicode character may appear inside a JSON string except three kinds, which must be escaped: the double quote, the backslash, and the control characters U+0000 to U+001F. A string starts and ends with a double quote, so an unescaped one would end it early, and the backslash is what starts an escape.
Seven characters have two-character escapes: \" for the quote, \\ for the backslash, and \b, \f, \n, \r and \t for backspace, form feed, line feed, carriage return and tab. Every other control character is written as \u and four hex digits, so U+001F is \u001f. That is exactly what this tool writes by default, and what JavaScript's JSON.stringify writes.
Any other character may be escaped too, but doesn't have to be. A character above U+FFFF is escaped as two \u escapes, the UTF-16 surrogate pair: RFC 8259's example is the G clef U+1D11E, written \ud834\udd1e. The option to escape everything outside printable ASCII is useful when the JSON passes through a system that mangles UTF-8. The forward slash may be written \/, which RFC 8259 allows but doesn't require.
Unescaping reads the text as the inside of a JSON string, with or without its surrounding quotes. It stops at the first thing JSON doesn't allow and says where it is: an escape JSON doesn't have, such as \' or \x41 from JavaScript, \u without four hex digits, an unescaped quote, or a raw line break that should have been \n.
" → \" \ → \\ / → \/ (optional) backspace \b form feed \f line feed \n carriage return \r tab \t other U+0000–U+001F → \u0000 … \u001f U+1D11E → \ud834\udd1e (surrogate pair, optional)
Which characters must be escaped in a JSON string?
| Code point | Character | Escape | Required? |
|---|---|---|---|
| U+0022 | " quotation mark | \" | Yes |
| U+005C | \ reverse solidus (backslash) | \\ | Yes |
| U+0000 | control character | \u0000 | Yes |
| U+0001 | control character | \u0001 | Yes |
| U+0002 | control character | \u0002 | Yes |
| U+0003 | control character | \u0003 | Yes |
| U+0004 | control character | \u0004 | Yes |
| U+0005 | control character | \u0005 | Yes |
| U+0006 | control character | \u0006 | Yes |
| U+0007 | control character | \u0007 | Yes |
| U+0008 | backspace | \b | Yes |
| U+0009 | tab | \t | Yes |
| U+000A | line feed (newline) | \n | Yes |
| U+000B | control character | \u000b | Yes |
| U+000C | form feed | \f | Yes |
| U+000D | carriage return | \r | Yes |
| U+000E | control character | \u000e | Yes |
| U+000F | control character | \u000f | Yes |
| U+0010 | control character | \u0010 | Yes |
| U+0011 | control character | \u0011 | Yes |
| U+0012 | control character | \u0012 | Yes |
| U+0013 | control character | \u0013 | Yes |
| U+0014 | control character | \u0014 | Yes |
| U+0015 | control character | \u0015 | Yes |
| U+0016 | control character | \u0016 | Yes |
| U+0017 | control character | \u0017 | Yes |
| U+0018 | control character | \u0018 | Yes |
| U+0019 | control character | \u0019 | Yes |
| U+001A | control character | \u001a | Yes |
| U+001B | control character | \u001b | Yes |
| U+001C | control character | \u001c | Yes |
| U+001D | control character | \u001d | Yes |
| U+001E | control character | \u001e | Yes |
| U+001F | control character | \u001f | Yes |
| U+002F | / solidus (forward slash) | \/ | No, optional |
| U+007F | delete (a control character JSON doesn't require escaping) | \u007f | No, optional |
| U+00E9 | é | \u00e9 | No, optional |
| U+20B9 | ₹ | \u20b9 | No, optional |
| U+2028 | line separator | \u2028 | No, optional |
| U+1D11E | 𝄞 G clef | \ud834\udd1e | No, optional |
How to escape or unescape a JSON string
- 1Choose escape or unescapeEscape turns text into something you can put between the quotes of a JSON string; unescape turns \n, \" and \u escapes back into the characters.
- 2Paste your textPaste the text, or the escaped string with or without its quotes. The result updates as you type, and nothing is sent anywhere.
- 3Pick the optionsWhen escaping, choose whether to write non-ASCII characters as \u escapes, whether to escape forward slashes, and whether to wrap the result in quotes.
- 4Copy the resultCopy the output. If unescaping fails, the error names the escape that isn't valid JSON and which character it is.
Frequently asked questions
Which characters have to be escaped in a JSON string?
How do I put a line break inside a JSON string?
Why is \' an invalid escape in JSON?
How is a character above U+FFFF written as a \u escape?
Is every JSON string a valid JavaScript string?
Sources
- RFC 8259, The JavaScript Object Notation (JSON) Data Interchange Format, §7 Strings and §8.2 (unpaired surrogates) (checked 20 Oct 2026)
- Ecma International, ECMA-404 The JSON data interchange syntax, 2nd edition (December 2017) (checked 20 Oct 2026)
- TC39, Subsume JSON (JSON superset) proposal: U+2028 and U+2029, included in ES2019 (checked 20 Oct 2026)
- MDN, JSON (JavaScript and JSON differences; the full JSON grammar) (checked 20 Oct 2026)
- MDN, JSON.stringify() (well-formed JSON.stringify: lone surrogates as \u escapes) (checked 20 Oct 2026)
Need a custom dev tool for your team?
We build internal tools, dashboards, APIs, and SaaS platforms. If you can describe it, we can ship it.
Built by CountryDevs · No signup · No ads · We count visits, never what you enter