TOOLGRID
HomeImage ToolsPDF ToolsVideo ToolsAudio Tools
More
Dev ToolsWeb & SEOCategoriesText ToolsCalculatorsAbout
Menu
HomeImage ToolsPDF ToolsVideo ToolsAudio ToolsDev ToolsWeb & SEOCategoriesText ToolsCalculatorsAbout
TOOLGRID

The full toolbox remains available when you need a specific utility.

© 2026 TOOLGRID. All rights reserved.

Tools

Image ToolsPDF ToolsVideo ToolsAudio Tools

Resources

CategoriesPrivacy Policy

Company

AboutTermsContact
  1. Home
  2. Converters
  3. JSON Escape / Unescape

JSON Escape / Unescape

Escape a string for safe embedding in a JSON value, or unescape a JSON-encoded string back to plain text.

Use this tool
Browser-local processingNo input upload to TOOLGRIDReview before copy
Formats and processing
Input
Pasted text or typed values
Output
JSON Escape / Unescape result
Runtime
Browser APIs
Browser-local workspaceStart below with browser-local processing.

Tool code processes selected files and entered content in your browser and does not submit them to a TOOLGRID processing endpoint. TOOLGRID measures tool usage, not the content you enter.

Loading tool…

Browser-basedWhat this tool does

In-browser JSON escape / unescape via JSON.stringify and JSON.parse. Optional outer-quote inclusion. Both directions supported.

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.

Representative tasks

What you can do with this tool

Embed a multi-line message in a Slack / Discord webhook

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.

Build a GraphQL query with string arguments

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.

Inspect a JSON-encoded value from a log or database

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.

Boundaries

What to check before relying on the result

  • Performance and maximum practical input size depend on browser memory, device speed, and the structure of the input.
  • Review the generated result before replacing or publishing an original file.
MDN Web APIs

How to use

  1. 1

    Pick Mode: Escape to encode plain text into JSON-safe form, or Unescape to decode it back.

  2. 2

    Toggle "Include outer quotes" in Escape mode if you want the full JSON string literal (with surrounding quotes).

  3. 3

    Paste your input. The escaped or unescaped output regenerates live as you type.

Use Cases
Embed a multi-line message in a Slack / Discord webhook

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.

Build a GraphQL query with string arguments

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.

Inspect a JSON-encoded value from a log or database

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.

Generate an env var holding a JSON value

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.

Convert a multi-line code snippet to a single-line JSON-safe string

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.

Tips & Tricks
JSON 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>&amp;</code>, spaces). HTML escape handles HTML-reserved characters (<code>&lt;</code>, <code>&gt;</code>, <code>&amp;</code>). Pick the encoding that matches the context the string will live in.

Outer 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.

Unicode 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.

Round-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

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>&lt;</code> and <code>&gt;</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?

JSON escape/unescape uses the browser's built-in <code>JSON.stringify</code> and <code>JSON.parse</code>. Tool code processes selected files and entered content in your browser and does not submit them to a TOOLGRID processing endpoint. Browser-local processing avoids a TOOLGRID upload path, but it is not a blanket security guarantee.

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).

Continue this workflow

Useful next steps

Open a nearby browser tool when you need to validate, convert, or reuse the result.

HTML Escape / UnescapeConverters · Local→URL Encoder & Decoder — Convert Text to URL-Safe FormatConverters · Local→JSON FormatterData Format · Local→