ZapKit

JSON Escape & Unescape

Make any text safe to put inside a JSON string, or turn an escaped string from a log or API back into readable text.

What is JSON escaping?

JSON escaping converts characters that would break a JSON string into backslash sequences. Without it, a quote inside the text ends the string early and a line break makes the whole document invalid.

Developers need it when building request bodies by hand, storing a snippet of HTML or a message template in a config file, embedding one JSON document as a string inside another, or putting text into environment variables. Unescaping is the reverse: logs, API responses and databases often show strings full of \n and \", and unescaping turns them back into the original text.

How to use the JSON Escape

  1. 1.Choose escape or unescape

    Escape to embed text in JSON; unescape to read a JSON string.

  2. 2.Paste the text

    Multi-line text, Windows paths and quotes are all handled.

  3. 3.Copy the result

    Optionally wrapped in double quotes, ready to drop into a JSON file.

Example: a message with quotes, a line break and a path

The text She said "hi", a line break, then "then left.", a tab and C:\Users\me:

Quotes
\"hi\"
Line break
\n
Tab
\t
Path
C:\\Users\\me

The escaped text can sit between double quotes in any JSON file and parses back to the original.

What gets escaped

JSON strings can't contain raw double quotes, backslashes or control characters. Escaping turns " into \", \ into \\, a line break into \n and a tab into \t, using the browser's own JSON encoder, so the output is always valid.

Escape non-ASCII adds \u codes for characters like é and emoji, for systems that only accept ASCII. Unescaping reads the text as a JSON string and reports the position of anything that isn't valid, such as \q or a lone backslash.

Frequently asked questions

Why do I see \\ in my JSON?

A single backslash in text is written as two in JSON. Windows paths like C:\Users become C:\\Users.

Do I need to escape single quotes?

No. Only double quotes delimit JSON strings, so ' stays as it is.

Can it unescape a value with the quotes included?

Yes. Paste it with or without the surrounding double quotes.

How do I escape a whole JSON object as a string?

Paste the object and choose escape. The result can be stored as a string inside another JSON document.

More Developer tools