Skip to main content

JSON Escape / Unescape

Escape text into a safe JSON string value, or unescape a JSON-escaped string back to raw text. Uses the exact rules of the JSON spec (RFC 8259): quotes, backslashes, and every control character are escaped. Toggle whether the output is wrapped in double quotes as a full JSON string literal.

Input

Escape mode only. On: output the complete "…" literal. Off: output just the escaped inner content.

Output

Result
Was this helpful?

Guides

Escape any text so it can be safely dropped into a JSON string value, or reverse the process and turn a JSON-escaped string back into plain, readable text. Paste your content, pick a mode, and the result updates instantly — everything runs in your browser, so nothing you type ever leaves your device.

What "escaping" means in JSON

A JSON string can't contain certain characters literally. Double quotes would end the string early, backslashes start escape sequences, and raw control characters (newlines, tabs, and everything else below U+0020) are simply not allowed inside a JSON string. Escaping rewrites those characters into safe sequences:

  • " becomes \"
  • \ becomes \\
  • newline, tab, carriage return, backspace, and form feed become \n, \t, \r, \b, \f
  • every other control character (U+0000–U+001F) becomes a \u00XX sequence
  • ordinary printable Unicode — accented letters, emoji, CJK — is left exactly as-is

The tool applies these rules by using the JavaScript engine's own JSON.stringify, which is the reference implementation of JSON string encoding. That guarantees the output matches the spec byte-for-byte rather than a hand-written approximation that might miss an edge case.

How to use it

  1. Paste your text into the input box.
  2. Choose Escape to encode plain text into a JSON-safe string, or Unescape to decode a JSON string back to raw text.
  3. In Escape mode, optionally turn on Wrap output in double quotes to get the complete "…" string literal you can paste straight into a JSON document. Leave it off to get just the escaped inner content.
  4. Copy or download the result.

Unescape mode accepts input either way — with or without the surrounding quotes — and reports a clear error if the input contains a malformed escape sequence.

How this differs from a generic "JS string escape" tool

JavaScript string escaping and JSON string escaping look similar but are not the same, and this tool implements the stricter, spec-defined JSON rules. JSON (RFC 8259) requires escaping every control character in the range U+0000–U+001F, and its only valid escapes are \", \\, \/, \b, \f, \n, \r, \t, and \uXXXX. A JavaScript-string escaper additionally allows things JSON forbids — single-quote escapes (\'), hexadecimal (\xXX) and octal escapes, line-continuations, and leaving some control characters unescaped. If you need output that a strict JSON parser will accept, use this tool; the looser JS-escape variant can produce strings that are valid in JavaScript source but rejected by JSON.parse.

Is my data private?

Yes. All escaping and unescaping happens locally in your browser using standard JavaScript. Your text is never uploaded to a server.

Common uses

Embedding multi-line text, code snippets, or user input into JSON config files and API payloads; cleaning up escaped strings copied out of logs; and quickly checking how a value will be serialized before it hits a strict parser.

jsonescapeunescapestringdeveloper

Love the tools? Lose the ads.

One payment clears every ad from your account, for good. No subscription, no tracking.