Skip to main content

JSON Escape & Unescape

Escape text for use inside a JSON string, or unescape a JSON string back to plain text. Handles quotes, backslashes, newlines, control characters, and Unicode. Runs in your browser.

Direction
Ctrl+Enter to Convert

What this tool does

Escape a block of text so it can sit inside a JSON string — quotes, backslashes, newlines, tabs, and control characters are all converted to their escape sequences. Unescape turns an escaped string back into the text it represents. Both directions use the browser’s own JSON implementation, so surrogate pairs and control characters behave exactly as a JSON parser expects.

What gets escaped

JSON requires exactly three things to be escaped inside a string: the double quote ", the backslash \, and every control character from U+0000 to U+001F. The common ones have short forms — \n, \r, \t, \b, \f — and the rest become \u00XX.

Everything else is left as written, because it is already legal: forward slashes, U+007F, accented letters, CJK text, and emoji all stay as themselves. Escaping them as \uXXXX would also be valid JSON, so this is a choice rather than a rule — leaving them readable is the more useful default.

An unpaired surrogate — half of a character that never got its other half — is escaped as a \uD800-style sequence, so the output is always well-formed even when the input is not.

Unescaping

Paste an escaped string with or without its surrounding quotes; both work. The input is parsed as a JSON string and nothing in it is ever executed — there is no eval and no Function constructor involved, so a payload that looks like code is treated as characters.

Input that is not a valid escaped string is rejected with the reason rather than repaired. A backslash before a character JSON does not escape, a real line break where \n was expected, or an unescaped quote in the middle will each say so — guessing at an intended meaning would risk changing your data.

Privacy

The text is escaped and unescaped locally in your browser. Nothing is uploaded, stored on our servers, or tracked.

Use cases

  • Embed a log excerpt or code block inside a JSON payload
  • Read an escaped string pulled out of an API response or a log line
  • Check why a JSON string with quotes or backslashes will not parse

Related tools

To format or validate a whole document rather than one string, use the JSON Formatter. If a document is failing to parse because of a raw newline or tab inside a value, Bad control character in string literal explains which characters are forbidden and why.

Need a different escaping format? Suggest a feature →