JSON Escape / Unescape
Escape a string for safe embedding inside a JSON value, or unescape a JSON-escaped string back to plain text.
Warum dieses Tool verwenden
05Free in-browser JSON escape and unescape tool. Use it when you need to embed text (multi-line strings, code with quotes and backslashes, log lines) inside a JSON string value — typically for webhook payloads, GraphQL string arguments, JSON-in-JSON config values, or environment-variable JSON strings. Optional outer-quote inclusion. Reverse direction decodes JSON-escaped strings back to plain text.
Paste any text and the tool produces a JSON-safe escaped version: " becomes \", \ becomes \\, newlines become \n, tabs become \t, and any non-ASCII characters that the JSON spec considers escapable get escaped. The output is ready to drop directly inside a JSON string value.
Toggle "Include outer quotes" on if you want the full JSON string literal (with leading and trailing ") ready to paste into a JSON document as-is. Off (default) gives you the inside of the string, which is what you usually want when concatenating or templating.
Switch to Unescape mode to go the other direction: paste a JSON-escaped string (with or without the outer quotes) and the tool decodes the escape sequences back to the original characters — useful when reading webhook payloads, copy-pasting strings out of JSON logs, or inspecting JSON-encoded values from a database.
All processing uses JavaScript's built-in JSON.stringify / JSON.parse — same rules as every JSON library and every browser. Nothing is uploaded. Pair with JSON Formatter when the surrounding document needs pretty-printing, or HTML Escape when the text will eventually be rendered as HTML.
So wird's verwendet
03Schnellcheck vor dem Kopieren
03Confirm the input is the format you intended.
Scan the result before using it in a document, URL, config, or message.
Copy only the output you need.
Anwendungsfälle
Webhooks expect a JSON body where the message text is a JSON string value. Multi-line messages or messages containing quotes break the JSON if pasted raw — escape them here first.
When sending a GraphQL query as a JSON body, the query string itself is a JSON value. Backslashes, quotes, and newlines inside the query need to be JSON-escaped — drop the raw query in to get the safe form.
Many systems store complex strings as JSON-encoded values (e.g., error stack traces with quotes). Paste the encoded form into Unescape mode to recover readable text.
When an environment variable needs to hold a JSON document (Vercel, Docker, Kubernetes), the variable value is a string and the JSON inside it must be self-consistent. Escape the JSON document with outer quotes off, then wrap with single quotes in your env file.
When sharing code samples in a JSON-based API (issue tracker, documentation system), the code becomes a JSON string. Escape converts your <code>\n</code>-separated code into a single-line escaped form that round-trips cleanly.
Tipps & Tricks
- 01JSON escape ≠ URL encode ≠ HTML escape
JSON escape handles characters that would break a JSON string value (<code>"</code>, <code>\</code>, control chars, newlines). URL encoding handles URL-reserved characters (<code>?</code>, <code>&</code>, spaces). HTML escape handles HTML-reserved characters (<code><</code>, <code>></code>, <code>&</code>). Pick the encoding that matches the context the string will live in.
- 02Outer quotes matter for paste-and-go
With outer quotes ON, the output is a complete JSON string literal you can paste directly into a JSON document. With OFF, you get the inside of the string — useful for template-string concatenation in code where you'll add quotes yourself.
- 03Unicode characters above U+FFFF use surrogate pairs
JSON encoding of emoji and rarely-used scripts uses the <code>\uHHHH\uHHHH</code> surrogate-pair convention. Most JSON parsers handle this correctly; if a downstream system rejects surrogates, that's a parser bug — not a JSON spec issue.
- 04Round-tripping is loss-free
Escape then immediately Unescape should return the exact original text. If it doesn't, the unescape input is malformed (typically a stray <code>\</code> at the end, or unclosed escape sequence). Watch for this when copy-pasting from formatted log output that may have wrapped lines mid-escape.
FAQ
07
What characters does JSON escape encode?
Per the JSON spec (RFC 8259): the quote character <code>"</code> becomes <code>\"</code>; backslash <code>\</code> becomes <code>\\</code>; control characters (U+0000 through U+001F) become <code>\u00XX</code> escapes; common ones have shortcuts: newline → <code>\n</code>, tab → <code>\t</code>, carriage return → <code>\r</code>, form feed → <code>\f</code>, backspace → <code>\b</code>. All other Unicode characters pass through unchanged (the spec allows raw UTF-8 in JSON strings).
What's the difference between Escape and Unescape modes?
Escape takes plain text and produces a JSON-safe version (e.g., <code>he said "hi"</code> → <code>he said \"hi\"</code>). Unescape goes the opposite direction. They're inverses: escape→unescape should give you back the original.
When should I include the outer quotes?
Include them (toggle ON) when you'll paste the result directly into a JSON document as a complete value. Exclude them (default OFF) when the output will be concatenated or templated into code that adds the quotes itself.
Is JSON escape the same as JavaScript string escape?
Very similar but not identical. JavaScript strings allow single quotes and a few escapes (like <code>\v</code> for vertical tab and <code>\x41</code> for ASCII) that JSON doesn't. Stick to JSON escape when the destination is JSON; use a JavaScript-specific encoder when the destination is JS source code.
What about HTML or URL contexts — can I use this output there?
No. JSON-escaped text is safe inside a JSON string; it's NOT safe in HTML (where <code><</code> and <code>></code> need entity encoding) or URLs (where reserved characters need percent-encoding). If the JSON value will eventually be rendered as HTML or used in a URL, apply additional layer-appropriate encoding on top.
Is my input sent to a server?
No. JSON escape/unescape uses the browser's built-in <code>JSON.stringify</code> and <code>JSON.parse</code>. Your input — including sensitive content like webhook secrets, log lines containing PII, or proprietary code samples — never leaves your device.
Why does Unescape fail on my input?
Most common causes: (1) the input has unbalanced escape sequences (a stray <code>\</code> at the end), (2) the input has unescaped control characters that the JSON spec doesn't allow, (3) the input is just plain text without any actual escapes (try running it through Escape first to see what valid escaped form looks like).
Verwandte Tools
03HTML-Escape / Unescape→
HTML-Entitäten escapen und unescapen.
URL Encoder / Decoder→
URL-sichere Textwerte enkodieren und dekodieren.
JSON Formatter→
JSON formatieren, minifizieren und validieren – alles an einem Ort.