Convert · Escape / Unescape

JSON Escape and Unescape

Escape JSON or text into a string literal you can drop into code, or unescape it back to the original. Runs in your browser.

No sign-up to start · Runs in your browser

JSON Escape / Unescape
Open in full editor
Text
Result

Runs entirely in your browser — nothing is uploaded.

{"name":"Ada","note":"line one
line two"}
JSON escaping turns text into a valid JSON string literal: it wraps the text in double quotes and escapes the characters JSON reserves — the double quote as \", the backslash as \\, and control characters like newline and tab as \n and \t. The result is a single value you can paste inside code, another JSON document, an environment variable, or a log line. Unescaping reverses it. JSON Copilot does both in your browser with an Escape/Unescape toggle.

Escape example

Input · raw text
{"path":"C:\\logs","msg":"line one
line two"}
Output · JSON string literal
"{\"path\":\"C:\\\\logs\",\"msg\":\"line one\nline two\"}"

The whole snippet is wrapped in quotes, every inner " becomes \", each backslash doubles — so C:\\logs becomes C:\\\\logs — and the real line break becomes \n. Unescape reverses it exactly.

How to escape or unescape JSON

  1. 1

    Pick a mode

    Use the Escape/Unescape toggle. Escape turns raw text into a JSON string literal; Unescape turns a literal back into the plain text it represents.

  2. 2

    Paste your text

    Drop your JSON, log line, or any string into the input — or start from the loaded example. Multi-line input is fine; newlines and tabs are handled.

  3. 3

    Read the output

    Escaping produces a double-quoted string with every reserved character escaped. Unescaping returns the original characters, with the surrounding quotes removed.

  4. 4

    Copy the result

    Copy the escaped literal to paste into source code or config, or copy the unescaped text to inspect what a string actually contained.

  5. 5

    Open the result in the editor

    If the unescaped text is JSON, open it in the full editor to format, validate, visualize it as a tree or mind map, and query it with the AI copilot.

Why use this tool

Runs in your browser

Escaping and unescaping happen 100% client-side. Your text never leaves your device — no upload, no account.

One toggle, both directions

Switch between Escape and Unescape without leaving the page or re-pasting your input.

Correct escape sequences

Double quotes, backslashes, newlines, tabs, and other control characters are escaped exactly as the JSON spec requires.

Lenient unescape

Paste an escaped string with or without its surrounding quotes — the tool wraps it if needed and still decodes it.

Catches double-escaping

Round-tripping through escape then unescape makes it easy to spot text that was accidentally escaped twice.

Funnels to the full editor

When your unescaped result is JSON, one click opens it in the editor for formatting, validation, and AI-assisted exploration.

What JSON escaping is (and when you need it)

A JSON string is a sequence of characters wrapped in double quotes. Because the double quote and the backslash have special meaning, and because control characters like newline and tab cannot appear literally, JSON defines escape sequences: \" for a quote, \\ for a backslash, \n for a newline, \t for a tab, \r for a carriage return, and \uXXXX for arbitrary code points. Escaping is the act of rewriting raw text so every reserved character is replaced by its escape sequence and the whole thing is quoted, producing a value that is legal wherever a JSON string is expected.

You reach for escaping whenever text has to survive being embedded inside another layer of syntax. The classic case is putting a JSON payload inside source code — a string constant in JavaScript, Python, Go, or a test fixture — where the surrounding quotes and any inner quotes would otherwise collide. It also comes up when nesting JSON inside JSON (a stringified value in an API field), when writing a JSON blob into an environment variable or a YAML/HCL field, and when a structured log line carries a message that itself contains quotes and line breaks.

The opposite problem — reading an escaped string and wanting the real content back — is just as common. A log aggregator shows you "{\"error\":\"timeout\"}" and you want the actual object; a config file stores an escaped blob you need to inspect. That is unescaping, and doing it by hand is exactly where mistakes creep in.

The escape sequences involved

Two characters are always escaped because they are structural: the double quote " becomes \" so it does not end the string early, and the backslash \ becomes \\ so it is treated as data rather than the start of an escape. This backslash rule is the one people underestimate: a Windows path like C:\logs\app contains backslashes that must each double, so the escaped form is C:\\logs\\app. Miss this and the string either fails to parse or silently loses characters.

Whitespace and control characters get short, readable escapes: newline is \n, carriage return is \r, tab is \t, backspace is \b, and form feed is \f. Any other control character below U+0020 is written as a \u escape, for example \u0000 for a null byte. Printable Unicode above the ASCII range can be left literal in UTF-8 JSON, so an emoji or an accented letter usually passes through unchanged rather than being expanded to \u sequences.

This tool escapes by treating your entire input as one string and producing its JSON literal, and it unescapes by parsing that literal back to characters. That means the mapping is exact and reversible: escape then unescape returns your original bytes, and unescape then escape returns the canonical literal. If you only need to see how a specific sequence like \t or \uXXXX renders, run it through Unescape and read the result.

Escape vs unescape, and the lenient unescape

The two modes are exact inverses. Escape takes plain text and adds structure — quotes plus escape sequences — so the text becomes a single safe token. Unescape strips that structure away, resolving each escape sequence back to the character it represents and removing the outer quotes. Use Escape when you are about to paste text into code or config; use Unescape when you have received an escaped string and want to read or process its real contents.

Unescape here is deliberately lenient about the surrounding quotes. A strict JSON parser rejects {\"a\":1} because a valid string must begin and end with a double quote, but in practice people copy escaped fragments without the outer quotes all the time — out of a debugger, a log field, or a diff. When your input does not already start with a quote, the tool wraps it in quotes before decoding, so both the quoted and unquoted forms unescape to the same result. What it will not do is invent structure for genuinely malformed input, such as a stray lone backslash with no valid escape following it; that reports an error rather than guessing.

One practical use of having both directions in one place is verification. Escape a value, then unescape the output, and confirm you get the original back — a quick sanity check before you commit an escaped literal into code that is hard to eyeball.

Common pitfalls: double-escaping and where the result goes

The most frequent bug is double-escaping: text that is escaped once, then escaped again by a later step. Each pass doubles the backslashes, so a clean \" becomes \\", \n becomes \\n, and the string stops decoding to what you meant. It typically happens when a value is escaped as it is stored and then escaped a second time as it is embedded, or when a tool auto-escapes input you had already escaped by hand. The fix is to unescape exactly once and inspect: if the output still shows escape sequences instead of real quotes and line breaks, peel off one more layer — you were escaping one level too many.

A related trap is escaping already-valid JSON when you actually wanted to keep it as JSON. Escaping collapses structure into a single string, so { and } become characters inside one literal rather than an object you can traverse. If your goal is cleaner JSON rather than an embeddable token, you want formatting or minifying, not escaping. And if you meant to nest one JSON document inside another as a string field, escape only the inner value, not the whole envelope.

Once you have unescaped a string and it turns out to be JSON, the natural next step is to work with it as data. Open the result in the full editor to format and validate it, visualize its shape as a collapsible tree or a mind map, and ask the AI copilot to explain, transform, or generate a schema from it. The escape tool gets you from an opaque literal to readable JSON; the editor is where you actually understand and reshape it.

Frequently asked questions

What does JSON escaping do?

It turns text into a valid JSON string literal — wrapping it in double quotes and escaping characters like ", \, newline, and tab — so it can live inside code, another JSON value, an env var, or a log line without breaking the syntax around it.

Is it free and private?

Yes. Escaping and unescaping run entirely in your browser with no account and nothing uploaded. Your text stays on your device.

How does the Escape/Unescape toggle work?

Escape reads your input as literal text and produces a quoted, escaped JSON string. Unescape reads an escaped string and produces the original characters. Flip the toggle to go either way on the same input.

Do I need to include the surrounding quotes to unescape?

No. Unescape is lenient: if your input is not already wrapped in double quotes, the tool adds them before decoding. So both {\"a\":1} and "{\"a\":1}" unescape correctly.

Which characters get escaped?

The reserved ones: the double quote becomes \", the backslash becomes \\, and control characters become their short escapes — newline \n, tab \t, carriage return \r, and so on. Ordinary printable characters are left as-is.

What is double-escaping and how do I avoid it?

Double-escaping is escaping text that was already escaped, so \" turns into \\" and the string no longer decodes to what you expect. It usually happens when a value is escaped once when stored and again when embedded. Unescape the string once and check: if you still see escape sequences, it was escaped twice.

How is this different from formatting or minifying JSON?

Formatting and minifying keep JSON as structured JSON — they only change whitespace. Escaping converts JSON (or any text) into a single string value; the braces and quotes become characters inside one literal rather than structure. Unescape turns that literal back into text you can format.

Where does my result go?

It stays on the page to copy. If the unescaped text is JSON, open it in the full editor to format, validate, and visualize it as a tree or mind map, and to ask the AI copilot about it.

Related tools

Escape or unescape your JSON

Open the Editor