JSON Escape / Unescape

Escape special characters in JSON strings, or unescape encoded JSON back to readable text. Handles quotes, backslashes, newlines, tabs, and all standard JSON escape sequences.

Mode:

JSON Escape Sequences Reference

CharacterEscape SequenceDescription
"\"Double quote
\\\Backslash
/\/Forward slash (optional)
newline\nLine feed (LF)
carriage return\rCarriage return (CR)
tab\tHorizontal tab
backspace\bBackspace
form feed\fForm feed
Unicode\uXXXXUnicode code point (4 hex digits)

When to use Escape

  • • Embedding JSON inside another JSON string value
  • • Storing JSON in a database text field
  • • Passing JSON as a URL parameter
  • • Writing JSON in configuration strings
  • • Embedding JSON in shell scripts or HTML attributes

When to use Unescape

  • • Decoding a JSON string received from an API
  • • Reading escaped JSON stored in a database
  • • Debugging minified or encoded JSON data
  • • Reverting escaped strings to readable format
  • • Converting \\n → actual newlines for display

About JSON Escape / Unescape

The JSON Escape / Unescape tool converts raw text into a safe JSON string value by escaping special characters — or reverses that process to restore the original readable text. It handles every character required by the JSON specification (RFC 8259), including quotes, backslashes, newlines, tabs, and Unicode code points.

  • Escapes ", \, \n, \r, \t, \f, \b, and \uXXXX
  • Single-pass unescape prevents double-processing bugs (e.g. \\n stays a literal backslash-n, not a newline)
  • Auto-detects whether your input looks already-escaped or raw, and suggests the right mode
  • Processes entirely in your browser — no data is sent to any server
  • Includes a built-in reference table for all standard JSON escape sequences

How to Use the JSON Escape Tool

  1. 1

    Choose a mode

    Click Escape to encode raw text into a JSON-safe string, or Unescape to decode an already-escaped JSON string back to readable text.

  2. 2

    Paste or type your input

    Paste your raw text or escaped JSON string into the left panel. The tool auto-detects the content and suggests the appropriate mode if it looks like a mismatch.

  3. 3

    Read the output

    The result appears instantly in the right panel as you type. You can also click → Escape String or → Unescape String to trigger manually.

  4. 4

    Copy the result

    Click Copy next to the output panel to copy the result to your clipboard in one click.

Tip: Use Load Example to see a realistic before/after demo. Switch modes after loading to understand both directions.

Common Use Cases

Embedding JSON in JSON

  • • Storing a JSON object as a string value inside another JSON document
  • • Passing serialized configuration via a JSON API field
  • • Wrapping structured data inside a message or payload string

Database & Config Storage

  • • Saving JSON blobs in plain text or VARCHAR columns
  • • Writing JSON values in .env or YAML config files
  • • Inserting escaped strings into SQL or NoSQL queries safely

Debugging API Responses

  • • Decoding double-escaped strings received from third-party APIs
  • • Unescaping \\n sequences in log output to see real newlines
  • • Reading minified or serialized JSON returned in a string field

Shell Scripts & CLI Tools

  • • Escaping JSON for use in curl -d request bodies
  • • Preparing JSON strings for jq or aws cli arguments
  • • Embedding JSON safely in Bash here-strings or single-quoted arguments

Frontend Development

  • • Escaping JSON for inline data-* HTML attributes
  • • Safely injecting server-rendered JSON into JavaScript string literals
  • • Preparing JSON for use inside HTML <script> tags

Testing & QA

  • • Generating escaped test fixtures for unit tests
  • • Verifying that an API correctly handles special characters like quotes and backslashes
  • • Comparing expected vs. actual escaped output during debugging

Frequently Asked Questions

What is JSON escaping?

JSON escaping replaces special characters in a string with their JSON-safe backslash sequences so they don't break the surrounding JSON structure. For example, a double quote " becomes \" and a newline becomes \n.

What is the difference between escaping and encoding?

JSON escaping uses backslash sequences defined by the JSON spec (\", \\, \n, etc.) to make a string safe inside a JSON value. Encoding usually refers to a different transformation — such as Base64 or URL encoding — which is a separate process for a different purpose.

Is my data safe? Does this tool send anything to a server?

No data leaves your browser. All escaping and unescaping happens entirely client-side in JavaScript. Nothing you paste into this tool is uploaded, stored, or transmitted anywhere.

Why does my escaped output look different from what I expected?

Make sure you're in the correct mode. If your input already contains escape sequences like \" or \n, you likely want Unescape, not Escape. The auto-detect badge at the top will hint which mode fits your input.

Does escaping a string and then unescaping it give back the exact original?

Yes — the round-trip is lossless. The unescape function uses a single-pass regex to avoid ordering bugs, so sequences like \\n (literal backslash + n) correctly stay as two characters and are not converted to a newline.

Does this tool escape forward slashes?

No. Escaping forward slashes (\/) is optional per the JSON spec and is almost never necessary. This tool follows the minimal-escaping approach and skips it, which produces cleaner output. Unescaping does handle \// for compatibility with tools that do escape slashes.

Can I escape Unicode characters?

The tool automatically escapes null bytes (\u0000) and control characters required by the JSON spec. For other Unicode characters, JSON allows them to appear as-is (UTF-8), so they are left unescaped. Unescaping fully supports any \uXXXX sequence in the input.

What's the difference between this tool and a JSON formatter/validator?

A JSON formatter pretty-prints a complete JSON document. This tool operates on a single string value — it escapes the content so it can safely sit inside a JSON string field, or unescapes a string value back to raw text. They solve different problems.