JSON Escape and Unescape - JSON String Tool Online
Escape JSON or any text so it can sit inside a JSON string, a log line or source code, or paste an escaped string to get the original text back. Quotes, backslashes, tabs, newlines and control characters are all handled.
How to escape or unescape JSON
- Choose a Direction: Escape to turn text into a string literal, or Unescape to turn a string literal back into text.
- Paste your input on the left. The result appears on the right as you type.
- Copy the result, or download it as a text file.
What gets escaped
Escaping follows the JSON specification, which is also what JavaScript, Python, Java, C# and most other languages accept in a double-quoted string:
- Double quotes become
\"and backslashes become\\. - Line breaks, carriage returns and tabs become
\n,\rand\t. - Other control characters become
\uescapes such as\u0000. - Letters with accents, emoji and other Unicode characters are left as they are, since JSON is UTF-8.
Options
- Surrounding quotes: include the opening and closing
", or leave them off when you are pasting into an existing string. - Compact JSON first: if the input is valid JSON, it is put on one line before it is escaped, so the result is short and has no
\nsequences from the indentation. Turn it off to keep the formatting exactly as you typed it. Input that is not JSON is always escaped as plain text.
When you need it
- Sending JSON as the value of a field inside another JSON document, for example a webhook payload or a message queue body.
- Putting JSON or multi-line text into a string in source code, a unit test or an environment variable.
- Reading an escaped string from a log file or a database column and seeing the original text.
Example
The text He said "hi" escapes to "He said \"hi\"", and the JSON {"path": "C:\\temp"} escapes to "{\"path\":\"C:\\\\temp\"}". Unescaping turns them back into text.
If what you have is stringified JSON and you want the object back as a formatted tree, the JSON Parser does that in one step, even when the JSON was encoded more than once.
Private by design
Everything runs in your browser and nothing is uploaded.