Escape & Encode /
JSON Escape
Paste or type anything. Every special character becomes a valid JSON escape as you type.
Text tools for people in a hurry
Escape & Encode /
Paste or type anything. Every special character becomes a valid JSON escape as you type.
JSON Escape turns any text into a valid JSON string. Paste a log line, a code snippet or a multi-line message and the output updates as you type: double quotes and backslashes get a backslash in front, line breaks become \n, tabs become \t and every other character below U+0020 becomes a \u00XX escape.
With the default settings the output is exactly what JavaScript's JSON.stringify produces, without the outer quotes, so it drops straight into an existing value. Options add the quotes for a complete literal, write non-ASCII characters as \uXXXX for systems that expect plain ASCII, and escape forward slashes for JSON embedded in an HTML page.
Everything runs in your browser and nothing you paste is uploaded. Swap sends the result to JSON Unescape so you can check the round trip in one click.
It rewrites the characters that cannot appear raw inside a JSON string so the text can sit between double quotes in a JSON document. Double quotes and backslashes are prefixed with a backslash, line breaks and tabs become \n and \t, and other characters below U+0020 become \u00XX escapes. With the default settings, letters, accented characters and emoji are kept as they are.
Yes. With the default settings the output matches JSON.stringify for the text in the editor, character for character, minus the surrounding quotes. Turn on Wrap output in quotes to get the complete literal.
When the JSON passes through something that may damage UTF-8, such as a legacy database column, an old API or a terminal with the wrong encoding. The option writes each character above U+007F as \uXXXX and each emoji as a pair of escapes. Any JSON parser reads the result back as the same text.
JSON never requires it, but writing / as \/ stops a closing script tag inside a string from ending an HTML script element early when JSON is embedded in a web page. Parsers read \/ back as a plain slash.
No. Escaping runs in your browser with JavaScript on this page. Your text is never sent to a server, logged or stored; only your option settings are remembered on this device.
Convert Markdown to clean, sanitized HTML with a live preview. GitHub tables, task lists and footnotes included.
↑↓ to move · ↵ to open · esc to close