100% Browser-LocalZero File UploadsVerify privacy →

JSON Unescape & Escape Tool

Instantly unescape double-escaped JSON strings from logs or escape raw JSON and text into valid RFC 8259 string literals—auto-detected as you paste, 100% locally in your browser.

0 chars
Output

How JSON String Escaping & Unescaping Works (RFC 8259)

JSON strings cannot contain raw double quotes, unescaped backslashes, or literal ASCII control characters (U+0000 through U+001F such as newlines and tabs). When backend services serialize a JSON payload inside another JSON field—common in Kibana, CloudWatch, Kafka, webhook logs, and Java/Go error wrappers—each serialization pass adds another layer of backslashes. This tool inspects your pasted text automatically, strips single or nested escape layers, and formats valid JSON without leaving your browser.

RFC 8259 Complete JSON Escape Sequence Reference

Every legal backslash escape defined by the official JSON specification and the parsing error triggered when left unescaped.

EscapeCode PointCharacterWhy it matters in APIs & logs
\"U+0022Quotation mark (")Must be escaped inside JSON strings; leaving it raw breaks JSON.parse with Unexpected token.
\\U+005CReverse solidus (\)Required for Windows file paths (C:\Users\dev) and regex patterns embedded in JSON.
\/U+002FSolidus (/)Optional in pure JSON, useful when embedding JSON inside HTML <script> tags to prevent </script> injection.
\nU+000ALine Feed (LF)Raw multiline breaks inside strings are illegal in strict JSON; always serialize as \n.
\rU+000DCarriage Return (CR)Windows CRLF line endings serialize as \r\n inside JSON strings.
\tU+0009Horizontal TabLiteral tab characters (0x09) inside strings fail strict RFC 8259 parsers unless encoded as \t.
\b / \fU+0008 / 000CBackspace / Form FeedLegacy control bytes rarely needed intentionally; often leak in from scraped PDFs or terminal logs.
\uXXXXU+0000–FFFF4-Hex Unicode EscapeEncodes any BMP character (e.g. \u4e2d); Emoji above U+FFFF use UTF-16 surrogate pairs like \uD83D\uDE00.

Single-Escaped vs. Double-Escaped JSON Diagnostic

Count the backslashes before a quote to tell immediately how many times a payload was stringified.

Layer 0

Normal JSON (Unescaped)

{"msg": "Hi \"dev\"\nOK"}

Standard JSON object ready for JSON.parse(). Backslashes only appear inside string values.

Layer 1

Single-Escaped String (1× \")

"{\"msg\": \"Hi \\\"dev\\\"\\nOK\"}"

Produced by one JSON.stringify() call or a JSON field storing serialized JSON (common in AWS API Gateway & webhooks).

Layer 2+

Double-Escaped Log (3× \\")

"\"{\\\"msg\\\":\\\"Hi\\\"}\""

Produced when an already-escaped JSON string is logged inside another JSON envelope (Kibana, CloudWatch, Sentry). Auto mode unwraps all layers at once.

Escape & Unescape JSON in Code & CLI

Production-safe recipes across JavaScript, Python, jq, and Go.

JavaScript / TypeScript

// Escape JSON object to string literal
const escaped = JSON.stringify(JSON.stringify({ msg: 'Hello "world"\nLine 2' }))

// Unescape (handles double-escaped payloads safely)
let value = escaped
while (typeof value === 'string') {
  try { value = JSON.parse(value) } catch { break }
}

Python

import json

# Escape text or JSON into a JSON string literal
escaped = json.dumps('{"msg": "Hello\nWorld"}')

# Unescape JSON string literal back to Python dict
decoded = json.loads(escaped)
if isinstance(decoded, str):
    decoded = json.loads(decoded)

jq (CLI Logs)

# Unescape a JSON string logged in Kibana / CloudWatch
echo '"{\"ok\":true,\"msg\":\"line1\\nline2\"}"' | jq -r . | jq .

# Escape raw file contents into a single JSON string
jq -Rs . payload.txt

Go

// Escape arbitrary text into a valid JSON string literal
b, _ := json.Marshal(rawText)
escaped := string(b)

// Unescape a JSON-encoded string literal
var unescaped string
_ = json.Unmarshal([]byte(escaped), &unescaped)

Frequently Asked Questions

Why does Auto mode unescape some JSON inputs and escape others?

Auto mode parses your input first. If the input is a valid JSON object or array (like {"a": 1}), it is already unescaped so the tool escapes it into a JSON string literal. If the input is a JSON string literal (like "{\"a\":1}") or an unquoted log snippet containing \" escapes, it automatically unescapes and pretty-prints it.

How do I fix double-escaped or triple-escaped JSON from Kibana or CloudWatch?

Simply paste the raw log string—whether it has outer quotes or not—with "Unwrap multi-layer escapes" enabled. The tool iteratively decodes each layer (up to 6 layers) until it reaches clean, valid JSON and shows the exact layer count.

When should I turn off "Wrap outer quotes" while escaping?

Disable outer quotes when you are pasting the escaped text directly inside an existing quoted string in a JSON file, cURL command, Java/Go source file, or Postman body so you do not end up with duplicate "" quotes.

Does JSON unescape convert \uXXXX Unicode escapes back to readable text?

Yes. Standard JSON unescaping automatically decodes \uXXXX sequences (including Chinese/Japanese characters and UTF-16 Emoji surrogate pairs) back into readable UTF-8 text.

Why does escaping forward slashes (\/) exist in JSON?

RFC 8259 allows escaping "/" as "\/" even though it is optional. Web frameworks enable it when embedding JSON directly inside HTML <script> tags so a string containing "</script>" cannot prematurely close the script block.

Are my API keys or production log payloads uploaded to a server?

Never. All detection, escaping, recursive unescaping, and file reading execute 100% locally inside your browser tab with zero network requests.