JSON Escape and Unescape
Turn a JSON document into a string you can paste inside another document, or read an escaped string back into the text it stands for.
Text
Syntax colouring is off for this document because recolouring something this large on every keystroke would slow typing down. Every tool still works normally.
Escaped
Syntax colouring is off for this document because recolouring something this large on every keystroke would slow typing down. Every tool still works normally.
The result appears here.
Warnings
Runs entirely in your browser. Nothing you paste is uploaded, and you can confirm that in your browser Network tab.
About this tool
Escaping is what a document needs before it can live inside a string: a JSON value holding another JSON document, a log line, a shell argument, a fixture pasted into a test. The rules are short and all of them are here. The characters with a short escape get it, control characters that have no short form become a \u escape, and a forward slash is left alone, because JSON accepts \/ and nothing requires it. Optionally everything above ASCII becomes a \u escape as well, which is what you want when the text has to cross something that is not certainly UTF-8. Neither direction requires valid JSON, since escaping part of a document is an ordinary thing to want, and the page says separately whether the result happens to parse.
How to use
- Choose Escape or Unescape, then paste your text into the left pane.
- When escaping, decide whether to wrap the result in quotes and whether to escape everything above ASCII.
- Press Convert, then copy the result. A bad escape is reported with the line and column it sits on.