On-device AI — professional-grade, fully private.

JSON String Escape Unescape

Escape text to a JSON string literal, or decode one back.

  • Nothing is uploaded
  • Nested layers peeled
  • Exact round trip
  • Errors show line and column

Drop a text file here

.json · .txt · .log · .ndjson · .jsonl and more · up to 10.0 MB on Free

Direction
Try an example:
Settings

All four are valid JSON. Turn one on when the place the literal is going cares.

Output
Pro

Free: 1 file up to 10.0 MB. Pro: 1 files, device-limited.

What this JSON escape and unescape tool does

Escape turns any text into a valid JSON string: wrapped in double quotes, with quotes, newlines, tabs, backslashes and control characters all escaped. Unescape does the reverse — paste a JSON string and get the plain text back. Paste it, pick a file, or drag and drop one. If Unescape cannot read the input, the tool names the rule that was broken and shows you where.

  • Escape — Wraps your text in double quotes and escapes internal quotes, newlines, tabs, backslashes and control characters, so the result is a valid JSON string literal that any parser accepts.
  • Unescape — Parses a JSON string such as "a\nb" and returns the plain string. A bare body without surrounding quotes works too, which is what you get when you copy a value out of a JSON file.
  • Paste, upload, or drop — Paste from the clipboard, use the file picker, or drag a file onto the drop area. UTF-8 and UTF-16 files are detected from their byte-order mark, so a file exported from PowerShell reads correctly instead of arriving as garbage.
  • Swap and start over — Swap sends the result back into the input and flips the direction, so a round trip is one press. Start over clears the queue, the result and the file picker together.

Escape and unescape: which one you need

When you embed user input or multi-line text in JSON or in source code, it needs proper escaping, or a quote or a newline breaks the syntax around it. Escape gives you the exact string literal to paste. When you already have an escaped string — out of an API response, a log aggregator, a configuration file — and you want to read the real text, Unescape reverses it. Both directions run instantly and keep working with no connection once the page has loaded.

  • Writing a config or a fixture — You have a multi-line certificate, SQL statement or template and need it as one JSON value. Escape it, and the newlines become \n rather than breaking the file.
  • Reading a log line — Structured logging serialises the message, and often the whole event a second time. Unescape it and the stack trace becomes readable lines again instead of one row of \n and \".
  • Debugging an API response — A field that arrives as a string containing JSON is a double-encoded payload. Unescape it once to get the inner document, then send that to the JSON Formatter.
  • Pasting into source code — A literal that is going into JavaScript, Python or Go needs its quotes and backslashes escaped. Escape without the surrounding quotes, and paste the body between quotes you already have.

Every character JSON escapes

The JSON grammar requires exactly two characters to be escaped inside a string — the double quote and the backslash — plus every control character below U+0020. Seven of those have a short two-character form; the rest use a \u00XX sequence. This is the complete list, and the tool produces exactly it.

CharacterEscaped asNotes
Double quote "\"Required. Ends the string otherwise.
Backslash \\\Required. Starts an escape otherwise.
Newline U+000A\nRequired. A literal newline is illegal inside a JSON string.
Carriage return U+000D\rRequired.
Tab U+0009\tRequired.
Backspace U+0008\bRequired.
Form feed U+000C\fRequired.
Other controls U+0000 to U+001F\u0000 to \u001fRequired. No short form exists.
Lone surrogate U+D800 to U+DFFF\u + D800 to DFFFAlways escaped here. It has no UTF-8 encoding, so leaving it raw loses the character when the file is saved.
Forward slash /\/Optional. Turn it on when the literal goes inside an HTML script block.
Non-ASCII above U+007F\u00e9, and 😀 as the pair D83D DE00Optional. Turn it on for an ASCII-only transport. Characters outside the basic plane become a surrogate pair of escapes.
Line separators U+2028, U+2029\u2028, \u2029Optional. Legal unescaped in JSON, and a syntax error in JavaScript before ES2019.
Delete U+007Fnot escapedJSON does not require it, so it is left as it is. Turning on non-ASCII escaping does not change this either — it is an ASCII character.

One consequence is worth spelling out: escaping and unescaping are exact inverses. Whatever combination of options you choose, unescaping the result gives back the text you started with, character for character, including whitespace at both ends.

Nested and double-escaped strings

The most common reason an unescape looks like it did not work is that the value was escaped more than once. Each round of serialisation doubles the backslashes, so a message that started as a newline becomes \n, then \\n, then \\\\n. One pass removes one layer, and what is left still looks escaped.

  • Leave the depth on Auto — The tool keeps peeling while the result is still a quoted JSON string, up to ten layers, and then stops. It tells you how many layers came off, so you always know what happened.
  • Set an exact depth to stop part way — Choose 1, 2 or any number up to 10 to peel exactly that many layers. Useful when the inner value is a document you want to hand to the JSON Formatter rather than decode further.
  • The peel test is deliberately strict — A layer is only removed when what is left is genuinely a quoted JSON string that parses. Ordinary prose that happens to mention \n is never peeled, so the tool cannot chew through text that was only ever plain.
  • Watch the layer count — If the tool reports fewer layers than you expected and the result still contains escapes, the remaining ones were never valid — usually a hand-edited log line with a stray backslash in it. Run Escape on the result to see exactly where it stops making sense.

Options at a glance

  • Wrap in quotes — On by default. The result is a complete JSON string literal, ready to paste as a value. Turn it off to get only the escaped body, for pasting between quotes that already exist in your source.
  • Escape non-ASCII as \uXXXX — Off by default. Every character above U+007F becomes a \uXXXX sequence, so the literal is pure ASCII. Emoji and other characters outside the basic plane become two escapes, which is what a parser expects.
  • Escape forward slashes — Off by default. Writes / as \/, which is legal JSON and stops the sequence </script> inside a string from closing an HTML script tag early.
  • Escape line separators — Off by default, and unavailable while non-ASCII escaping is on because that already covers it. Writes U+2028 and U+2029 as escapes so the literal is safe to paste into JavaScript source.
  • Unescape depth — Auto by default. Controls how many layers of nesting are removed. See the section above.
  • Counts and ratio — Every result shows characters in and out, bytes in and out, and the growth ratio — the number that matters when the value has to fit a column or a payload limit.

What each error message means

When Unescape refuses, it names the rule that was broken and gives the line and column, computed from the position in your text rather than read out of a parser's own English message. That is why the message is in your language and the highlighted position is correct on every locale.

MessageWhen it happensWhat to do
The string is never closedThe text has an opening quote with no matching closing quote — usually a value that was truncated by a log limit or a copy that stopped short.Add the closing quote, or paste the whole value.
Unknown escape sequenceA backslash is followed by a character JSON does not define, such as \q or a Windows path pasted without doubling its separators.Double the backslashes, or use Escape on the original text to produce a correct literal.
Incomplete \u escapeA \u is not followed by exactly four hexadecimal digits.Complete the four digits. \u12 is not a valid escape; \u0012 is.
Raw control characterAn actual newline or tab appears inside the string instead of \n or \t. This is the most common failure when a value is pasted out of a terminal.Run Escape on the text instead — that is exactly what it is for.
Extra content after the stringTwo strings sit side by side, like "a" "b", or something follows the closing quote.Convert one value at a time, or join them into a single string first.
That is a JSON document, not a stringThe input is an object or an array. Unescape works on one string value.Send it to the JSON Formatter or the JSON Validator instead — both are linked from the message.

Limits, speed and privacy

Everything happens on your own device. There is no upload step, no queue on a server and no copy of your text anywhere but in the tab you have open. That is also why it is fast: nothing has to travel.

  • Free — One file at a time, up to 10 MB, with every option and every depth available. Pasting goes through the same check, so there is nothing to work around.
  • Pro — No fixed size cap — up to what your device can handle — plus up to 20 files at once and every result delivered as a single archive.
  • Speed — A 10 MB document escapes in about 22 milliseconds and unescapes in about 21. Conversion runs off the main thread, with progress and a Cancel button that genuinely stops the work rather than hiding it.
  • What is never sent — Your text, your file names and your results. The tool keeps working after the page has loaded even with the network switched off, which is the simplest way to check the claim yourself.
  • Formats it opens — .json, .txt, .log, .ndjson, .jsonl, .md, .csv, .tsv, .xml, .yaml, .yml, .sql, .env and .ini. Anything else is refused at the file picker, with a link to the tool that does open it — a spreadsheet goes to Excel to JSON, a document to Word to text.

A 10 MB document escapes in about 22 milliseconds on a mid-range laptop, and runs off the main thread so the page never freezes.

Frequently asked questions

How does the JSON escape tool work?

Choose Escape or Unescape, then paste your text or load a file. Escape wraps your text in double quotes and escapes internal quotes, backslashes, newlines, tabs and control characters to produce a valid JSON string literal. Unescape reverses that, parsing a JSON string back to plain text. The result appears beside your source with character and byte counts, and you can copy it, download it, or swap it back into the input.

Is my data secure?

Your text is never sent anywhere. Escaping and unescaping both run on your own device, so nothing is uploaded, nothing is stored and nothing is logged — and once the page has loaded the tool keeps working with no connection at all. Files you drop are read locally and released when you clear the queue.

What is the difference between escape and unescape?

Escape converts plain text into a JSON string literal: it adds surrounding double quotes and backslash-escapes special characters so the value is safe to paste into JSON or code. Unescape does the opposite, taking a JSON string and returning the original raw text, decoding sequences like \n, \t and \" back to real characters.

Which characters get escaped?

The characters JSON requires: double quotes become \", backslashes become \\, newlines become \n, carriage returns \r, tabs \t, backspace \b, form feed \f, and every other character below U+0020 becomes a \u00XX sequence. Lone surrogates are always escaped as well, because they have no valid UTF-8 encoding and would otherwise be replaced when the file is saved. Three optional toggles add \uXXXX for non-ASCII characters, \/ for forward slashes, and \u2028 / \u2029 for the two Unicode line separators.

What input does Unescape expect, and what if it fails?

It accepts a JSON string with its quotes, like "hello\nworld", and also a bare escaped body without them, like hello\nworld — which is what you get when you copy a value out of a JSON file. Surrounding whitespace is ignored for a quoted string and preserved for a bare one. If the input is not a valid string, the tool names the rule that was broken, gives the line and column, and shows the surrounding text with links to the JSON Formatter and Validator.

Can it handle double-escaped or nested strings?

Yes. A log line that has been serialised two or three times comes back with \\n and \\\" still in it after a single pass. Leave the depth on Auto and the tool keeps peeling while the result is still a quoted JSON string, up to ten layers, then tells you how many it removed. Set an exact depth if you want to stop part way and inspect an intermediate layer.

Why would I escape non-ASCII characters or forward slashes?

Escape non-ASCII as \uXXXX when the value has to travel through something that is not reliably 8-bit clean, or when you want the literal to be pure ASCII in source control. Escape forward slashes when the string will be embedded inside an HTML script block, where the sequence </script> inside a string would otherwise end the tag early. Both are valid JSON either way — the toggles exist because the destination sometimes cares.

What are U+2028 and U+2029, and why is there a toggle for them?

They are the Unicode line separator and paragraph separator. They are perfectly legal unescaped inside a JSON string, and until ES2019 they were illegal inside a JavaScript string literal — so a JSON string pasted straight into JavaScript source could be a syntax error pointing at a character you cannot see. The toggle escapes them so the literal is safe to paste anywhere.

How large a file can I use, and does it work on mobile?

Free handles one file up to 10 MB. Pro removes the fixed cap and works up to what your device can handle, takes up to 20 files at once and delivers every result as a single archive. Pasting has no separate limit — it goes through the same check. The tool runs in any modern browser on desktop, tablet and phone, and large documents are converted off the main thread so the page stays responsive.

4.8out of 5

from 65 ratings

Rate this tool

Tap a star — it takes a second