JSON Escape / Unescape
Repair escaped JSON strings from logs, or escape JSON into a string literal for source code. Runs entirely in your browser.
Escaped JSON string
Unescaped JSON
Paste an escaped JSON string to repair it
Results update as you type. Nothing leaves your browser, and nothing is stored.
Details
Paste an escaped JSON string (for example a payload copied from application logs, wrapped in quotes and full of \n, \" or \uXXXX sequences) and the tool strips one layer of string-literal escaping, parses the result and pretty-prints it with your chosen indentation. If the text is not valid JSON after unescaping, the escape layer is still removed and the repaired text is shown with the parser error position so you can fix it. Escape mode does the reverse: paste valid JSON and get a single-line string literal ready to paste into JavaScript, Python or another source file, with double, single or backtick quoting and an optional ASCII-only output that re-escapes non-ASCII characters as \uXXXX. Input that is already valid JSON is formatted only — never double-unescaped — and the transparency report shows exactly which steps were applied.
More examples
Repairing a log line
Input:
"{\"a\": 1, \"b\": [2, 3]}"
Output:
{
"a": 1,
"b": [
2,
3
]
}The outer quotes are stripped, the escape layer is decoded in one pass and the payload is pretty-printed.
Decoding escaped unicode
Input:
"{\"city\": \"M\u00fcnchen\"}"
Output:
{
"city": "München"
}\uXXXX escapes decode to literal UTF-8 characters; the ASCII-only toggle keeps them escaped instead.
Escaping JSON for source code
Input:
{"tpl": "Hello ${name}"}
Output (backtick style):
`{"tpl":"Hello \${name}"}`The JSON is serialized to one line and re-escaped for the chosen quote style; backtick output also escapes ${ so templates cannot interpolate.
Examples
Log line to pretty JSON
"{\"id\": 9007199254740993, \"msg\": \"done\"}"{
"id": 9007199254740993,
"msg": "done"
} (with a 2^53 precision warning)The escape layer is removed and the payload pretty-prints; the oversized integer is flagged because JavaScript parsing rewrites its last digit.
Already-valid input
{"msg": "line1\nline2"}Formatted only — "Input was already valid JSON" noticeEscapes inside an already-valid document are left untouched; the tool never double-unescapes.
Embedding in a Python string
{"s": "it's"} with single-quote style'{\"s\":\"it\'s\"}'The chosen quote char and backslashes are escaped; double quotes pass through unescaped inside single-quoted literals.
About this tool
Escaped JSON is everywhere in day-to-day debugging: application logs, curl transcripts, HAR exports and error trackers routinely show payloads as a single quoted string stuffed with \n, \" and \uXXXX sequences. A generic JSON formatter refuses that input outright because the text is a string literal, not a JSON document, and generic string escapers do not implement JSON's exact escape set, so round-trips silently corrupt the data. This tool closes that gap: Unescape mode strips one layer of string-literal escaping with a strict single-pass scanner, parses the repaired text and pretty-prints it with your chosen indentation — and if the payload still is not valid JSON, you get the parser error position plus the repaired text, which stays copyable.
Escape mode is the reverse path for embedding JSON in source code. It serializes your JSON to a single line and re-escapes it for double quotes (JSON, JavaScript), single quotes (JavaScript, Python) or backticks (JavaScript templates, where ${ is escaped so the embedded JSON can never interpolate). An ASCII-only option re-escapes non-ASCII characters as \uXXXX, and an optional forward-slash escape covers embedders that prefer \/. Everything runs locally in your browser — log payloads often contain tokens and personal data, so nothing is uploaded and nothing is stored.
The tool is deliberately honest about what it changes. A transparency report lists each applied step (outer quotes stripped, N escapes decoded, parse ok or failed), input that is already valid JSON is formatted only — never double-unescaped — and non-canonical numbers, integers beyond 2^53 − 1 and duplicate keys are flagged, because parse → stringify rewrites exactly those without changing the shape of the document.
What this tool does not do
- One escape layer per run; a multi-layer control and batch log-line extraction are planned follow-ups.
- Parse error positions come from the engine's JSON.parse message; engines that report neither a position nor line/column show the error without a marked offset.
- Lone surrogate escapes decode as-is (and are flagged) but cannot survive a UTF-8 download — they become � when written to a file.
How to use this tool
Pick the mode
Unescape repairs an escaped JSON string into pretty JSON; Escape turns valid JSON into a single-line string literal for source code. The same textarea changes meaning with the toggle.
Paste and review the report
Paste the log line or payload. The transparency list under the result shows whether outer quotes were stripped, how many escapes were decoded and whether JSON.parse succeeded.
Choose output formatting
In Unescape mode pick 2 spaces, 4 spaces or tab indentation, and decide whether non-ASCII stays as \uXXXX or decodes to literal characters. In Escape mode pick the quote style and optional ASCII-only or \/ output.
Fix failures in place
If the unescaped text is not valid JSON, the error shows the parser position and the repaired text remains copyable — fix the marked spot or paste it into the JSON Formatter.
Use cases
Debugging logged payloads
Paste an escaped request body straight from application logs or an error tracker and read it as formatted JSON, with the escape layer's steps reported.
Embedding JSON fixtures in code
Turn any JSON document into a safely escaped single-line literal for JavaScript, Python or template-literal contexts, with ASCII-only output when the target file must stay ASCII.
Extracting bodies from curl and HAR output
Strip the shell's quoting and escaping layer from captured request bodies before inspecting or diffing them.
The JSON escape set (RFC 8259 / ECMA-404)
| Escape | Decodes to |
|---|---|
| \" | Double quote " |
| \\ | Backslash \ |
| \/ | Slash / (accepted on input; emitted only when the option is on) |
| \b \f \n \r \t | Backspace, form feed, newline, carriage return, tab |
| \uXXXX | One UTF-16 code unit from exactly four hex digits; surrogate pairs combine |
| Anything else after \ | Rejected with its position — strict JSON semantics, no silent guessing |
Input whitespace and trailing newlines from log pastes are trimmed before quote detection.
Common mistakes
Mistake:Running an unescape twice by reflex.
Fix:One run removes exactly one escape layer. Already-valid JSON is detected and formatted only; when the result still looks like an escaped literal, the tool tells you a second pass is warranted instead of guessing.
Mistake:Assuming the escaped string is the JSON document.
Fix:A top-level string value like "{\"a\": 1}" is itself valid JSON — the tool treats it as an escaped literal and unwraps it rather than merely re-formatting it.
Mistake:Copying long IDs out of the pretty output and trusting them.
Fix:Integers above 2^53 − 1 (64-bit snowflake IDs) get their last digit rewritten by JavaScript parsing. Compare long IDs against the original text; the tool warns when it detects them.
Mistake:Expecting lenient escapes like \x41 to decode.
Fix:JSON defines a fixed escape set. Unknown escapes are reported with their exact position instead of being silently mangled — fix the source string or escape the backslash as \\.
Frequently asked questions
Why is my JSON full of backslashes?
The payload you copied is not raw JSON — it is a JSON string literal: a document that was serialized, then escaped again when it was embedded in another string (a log line, a shell argument, a serialized error report). Every quote became \" and every newline became \n. Unescape mode removes exactly that one escaping layer and hands you the underlying document, pretty-printed.
What escapes does JSON use (and not use)?
The set is fixed by RFC 8259: \" \\ \/ \b \f \n \r \t and \uXXXX (exactly four hex digits). Anything else after a backslash — \x41 for example — is invalid JSON, and the tool reports it with its position instead of silently guessing what you meant. That strictness is what keeps round-trips lossless.
How do I unescape \/ and \uXXXX?
\/ is a valid (optional) escape and always decodes to / on input. \uXXXX decodes to one UTF-16 code unit; adjacent surrogate escapes such as \uD83D\uDE00 combine into the single character 😀. By default non-ASCII decodes to literal characters; the "Keep \uXXXX escapes" switch re-escapes them in the output instead, and Escape mode has the same choice as an ASCII-only output option.
Can I paste the outer quotes?
Yes — with or without them. If the first and last characters (after trimming log-line whitespace) are a matched " or ' pair, the tool strips that pair as one step and reports it in the transparency list. A leading quote without its closing partner is reported as an unbalanced quote rather than being ignored.
Why does double-unescape corrupt my data?
Each pass removes one layer. If you unescape text that was only escaped once, the remaining backslashes get decoded as literal data: \\n becomes a real newline, \\" becomes a stray quote, and the document breaks or — worse — its string values change silently. The tool never unescapes input that already parses as JSON (it formats it instead) and warns when the result still looks like another escaped layer, so a second run stays a deliberate choice.
Why does my long ID change in the output?
JavaScript numbers are 64-bit floats, so integers above 2^53 − 1 — 64-bit snowflake IDs, for instance — lose precision the moment JSON.parse touches them, and parse → stringify rewrites non-canonical numbers like 1.0 or 1e5. The meaning of the document does not change, but the literal digits can. The tool detects these patterns in the raw text and warns so you can compare long IDs against the original.
Is my data sent anywhere?
No. All parsing and escaping runs in your browser tab; nothing is uploaded, logged or stored. That matters here specifically because logged payloads frequently contain tokens, personal data or secrets.
References & standards
Related tools
Base32 Encoder / Decoder
Encode and decode Base32 (RFC 4648) with hex input mode and Crockford variant. Handles TOTP secrets. Runs in-browser.
Base58 Encoder / Decoder
Convert hex or text to Base58 and back, with Base58Check validation (version byte + checksum). IPFS CIDs too. In-browser.
Base64 Toolbox
Professional Base64 workspace for text, files and images with Base64URL, MIME, Data URI, strict validation, image preview and ready-to-use snippets.
BibTeX to JSON Converter
Parse .bib bibliographies into structured JSON with authors, months, macros and LaTeX cleanup, all in-browser.
C# to VB.NET Converter
Convert a subset of C# — classes, methods, variables, loops — into VB.NET
CSV Data Viewer
Paste CSV and inspect it as a sortable, searchable table with delimiter detection and inline export.