JSON Escape / Unescape
Escape text for use inside a JSON string, or unescape stringified JSON back to readable text. Handles quotes, backslashes, line breaks and Unicode escapes.
Runs in your browser · Nothing uploaded · No sign-up
Something not working, or missing a feature? Send feedback
About the JSON Escape / Unescape
JSON Escape turns any text into the contents of a JSON string by escaping quotes, backslashes, line breaks and control characters. JSON Unescape does the reverse and turns stringified JSON such as "{\"id\":7}" back into readable text, showing it formatted when the result is a JSON object or array.
Everything runs in your browser, so your input is never uploaded to a server.
How to use the JSON Escape / Unescape
- Choose Escape to embed text in a JSON string, or Unescape to read a string that was escaped.
- Paste the text. For Unescape the surrounding quotes are optional.
- Optionally keep the quotes or escape non-ASCII characters as \uXXXX, then copy the result.
Examples
Input
He said "hi" Path: C:\temp\app.log
Result
He said \"hi\"\nPath: C:\\temp\\app.log
Quotes, the line break and the backslashes are escaped, so the result can sit between double quotes in a JSON file.
Input
"{\"id\":7,\"tags\":[\"a\",\"b\"]}"Result
{
"id": 7,
"tags": [
"a",
"b"
]
}The quotes and escapes are removed, and because the result is a JSON object it is shown formatted.
Common mistakes
- Escaping twice. Escaping text that is already escaped doubles every backslash (\n becomes \\n). Escape once, at the point where the string is created.
- Single backslashes in paths. C:\temp\new is read as a tab and a line break. Escape the path first, so each backslash is doubled.
- Pasting a whole JSON document. To embed a document as a string, escape it here. To format a document, use the JSON Formatter: an escaped document is no longer readable as JSON.
Works well with the JSON Escape / Unescape
- JSON Formatter: format the unescaped document.
- Unicode Escape / Unescape: convert only the non-ASCII characters to \u escapes.
- JSON Repair: fix a document that does not parse after unescaping.
Frequently asked questions
Which characters are escaped?
Double quotes, backslashes and the control characters (line break, tab, carriage return, backspace, form feed and the rest below U+0020). The forward slash is left alone, because JSON does not require escaping it.
Why do I get an error when I unescape?
The text contains a backslash that does not start a valid JSON escape, such as \d or a Windows path with single backslashes. The error shows the line and column. Double the backslash (\\) or escape the original text first.
How do I unescape JSON that was escaped twice?
Unescape it once, then paste the result in again. Every pass removes one level of escaping, so a string that was stringified twice needs two passes.
What is the difference between this and JSON.stringify?
For a string, JSON.stringify gives the same escapes plus the surrounding quotes. Turn on Surrounding quotes to get exactly that output.
Related tools
Base64 Encode / Decode
Encode text to Base64 or decode Base64 to text online, with full UTF-8 and URL-safe Base64 support. Conversion runs in your browser, so nothing is uploaded.
URL Encode / Decode
URL encode or decode text online: percent-encode query string values and full URLs, or turn %20-style escapes back into readable text.
HTML Entity Encode / Decode
Encode special characters as HTML entities or decode entities such as & and < back to text. Escape user content safely before adding it to a page.
JWT Decoder & Verifier
Decode JSON Web Tokens online: inspect the header and claims, check expiry and verify HMAC signatures. Tokens are decoded locally and never leave your browser.
JWT Generator
Create signed JSON Web Tokens online with HS256, HS384 or HS512 from a custom header and payload. Signing happens in your browser; the secret stays local.
Unicode Escape / Unescape
Convert text to \uXXXX Unicode escape sequences and back online, including emoji and astral characters. Handy for JavaScript, JSON and Java strings.