How to Use This Tool
Paste text to escape it for a JSON string, or paste an escaped string to get it back. The growth table shows what each further level of nesting costs.
What actually needs escaping
The list is shorter than most people assume. Inside a JSON string, exactly three things must be escaped:
- Double quote —
\", because it would end the string. - Backslash —
\\, because it starts an escape. - Control characters below U+0020 — newline, tab, carriage return and the rest,
either as their shorthand or as
\u00XX.
That is all. Single quotes need nothing. Non-ASCII characters need nothing — JSON is Unicode and
é, 中 and emoji are all legal literally. Escaping them as \u sequences is valid and
makes the document larger and less readable for no benefit.
The forward slash question
A forward slash does not need escaping, and a lot of tools escape it anyway. The
convention comes from embedding JSON inside an HTML <script> tag, where the sequence
</ would terminate the tag early — escaping the slash prevents that.
If your JSON is going into a script tag, keep it. Everywhere else it is noise, and both forms parse identically. The option is there because you will meet both.
When the nesting is the problem
Each level roughly doubles the escaped length: 7 characters become 11, then 19, then 35. That is already unreadable at level two and unmaintainable at level three — you cannot edit it by hand without miscounting a backslash, and you cannot review a diff of it at all.
If you find yourself at two levels, the structure is usually the thing to fix rather than the escaping:
- Store the inner document as an object, not as a string containing a document. Most databases and APIs accept nested objects directly.
- Base64 the payload if it genuinely must be opaque text. It is larger but has no escaping at all, so it survives any number of layers unchanged.
- Keep it in a separate field or file and reference it.
Over-escaping is the usual bug
A string that arrives as \\"hello\\" when you expected "hello" was escaped
once too often — typically because a value was already a JSON string and something serialised it
again. The fix is upstream: find the layer applying the second escape, rather than unescaping twice to
compensate, which breaks the moment the input arrives correctly escaped.
