JSON Escape and Unescape

Escape text to embed inside a JSON string, or unescape a JSON string back to plain text. Handles quotes, backslashes, and control characters.

Independently verified for accuracy

Calculator by Toolsloft ↗

Escape text so it can sit inside a JSON string, or unescape a JSON string back to plain text. Escaping handles quotes, backslashes, and control characters like tabs and newlines the way the JSON spec requires. Useful when you are hand-editing JSON, embedding a snippet in a config file, or reading an escaped value from a log.

How this is calculated

Escaping follows RFC 8259: the double quote and backslash are prefixed with a backslash, the common control characters use their short forms (\b, \t, \n, \f, \r), and any other character below U+0020 is written as \u00XX. Unescaping parses the escape sequence as a JSON string and reports an error if it is not valid.

How to use

  1. Choose escape to encode text for JSON, or unescape to decode it.
  2. Type or paste your text into the input box.
  3. Copy the converted result.

Examples

  • Escape: "quote" becomes \"quote\"
  • Unescape: a\nb becomes a line break

FAQ

Does the output include the surrounding quotes?
No. It escapes only the body of the string, so you can paste it between your own quotes. That makes it easy to drop the result straight into a JSON value you are editing.
How are newlines and tabs handled?
A newline becomes \n, a tab becomes \t, and other control characters below U+0020 become \u00XX. This matches the escaping used by JSON.stringify.
What happens if I unescape invalid input?
If the text contains an escape sequence that is not valid JSON, such as a lone backslash followed by an unsupported letter, the tool reports that the input is not a valid JSON string escape instead of guessing.

Embed this calculator

Add this free calculator to your own site. Copy the code and paste it where you want it to appear.