Escape or unescape JSON without guessing at the backslashes
JSON is easy to read until a message has to travel inside another message. Quotes, line breaks, and backslashes then need a representation that survives each string boundary. This guide shows what the conversion does, when to use one or two passes, and how to get from a noisy log value back to readable JSON.
Before · the log line
An API response is hard to scan
A support engineer copies a webhook record into a ticket. Its body field contains a complete JSON document, so quotes appear with backslashes and line breaks are stored as \n. The payload is valid, but a quick glance cannot tell where the body ends and the surrounding event begins.
{"event":"shipment.ready","body":"{\"status\":\"ready\"}"}After · inspect one layer at a time
Decode, check, then format
The engineer pastes the record, chooses Unescape 1× for the body value, and checks the output. Once the inner document is visible, the Format control lays out its keys on separate lines. The payload can now be reviewed, attached to a bug report, or compared with the expected webhook fixture.
What changes
A JSON string has its own rules
In JSON, a quotation mark cannot appear unescaped inside a quoted string. A backslash introduces an escape sequence, while characters such as a newline or tab need an escaped representation when they occur inside a string. A JSON escape tool applies those rules to the content you provide. It returns the string contents without adding the outer quote marks required by some destination fields.
Unescape reverses that operation. The result may be readable prose, or it may be another JSON document that needs to be parsed and formatted. The distinction matters: decoding characters is not the same as validating the document that remains.
The behavior follows the string rules in RFC 8259, section 7. An escaped forward slash is permitted by the standard but optional; ordinary URL slashes do not need to become backslashes.
One payload, three views
JSON escape example
The outer quotation marks are omitted in these string-content examples.
{"status":"ready","message":"Saved"}{\"status\":\"ready\",\"message\":\"Saved\"}{\\\"status\\\":\\\"ready\\\",\\\"message\\\":\\\"Saved\\\"}At 2×, each layer has to preserve the escapes from the previous layer. That is why several backslashes can appear together before a quote. Use the depth your receiving field expects, not the depth that merely looks shorter.
How to use the JSON escape and unescape tool
A short pass through the editor keeps the conversion easy to verify.
- 01
Paste or load
Enter JSON, an escaped string, or plain text in the Input editor. You can use the sample control, choose a local JSON, TXT, or LOG file, or drop a supported file onto the editor.
- 02
Choose a direction
Use Escape to prepare JSON text for a string field. Use Unescape to decode a value copied from an API response, config, database record, test fixture, or log.
- 03
Choose the layer count
Start with 1× for a single string boundary. Choose 2× when the value has been serialized twice. The result label shows which conversion ran.
- 04
Review and take the result
Check the output before using it. If it is valid JSON, Format makes it easier to read and Minify removes layout whitespace. Then copy or download the text.
Choose deliberately
When do I need JSON Escape 2×?
Imagine a test fixture that stores a webhook body as a string in an event object. One JSON string boundary needs one escape pass. If another service then stores that entire event as a string inside a second JSON record, the content crosses a second boundary and needs a second pass. The 2× button performs both passes in one action. It does not mean “add two slashes to every character.”
The reverse workflow is the same in steps: decode two known wrappers, check whether the inner text is JSON, then format it. If a single unescape still leaves \" sequences, that can be evidence of another wrapper. But Windows paths, regular expressions, and ordinary text also contain backslashes; their presence alone is not a reason to select 2×.
Good fit for
Everyday JSON handoffs
- API debugging: read a quoted response body from a trace, then format the decoded object.
- Test data: place a fixture inside a JSON string field and reproduce the same nesting in a request or mock.
- Configuration review: decode stored JSON text from a setting or database value before changing its structure.
- Support handoffs: turn a hard-to-read log value into a compact example teammates can inspect and discuss.
A useful boundary
JSON escaping is not a universal sanitizer
The same text can move through several languages, and each has its own quoting and safety rules. A string that is valid JSON is not automatically safe to concatenate into an SQL statement, insert into HTML, place in a shell command, or paste into a JavaScript or Python literal. Use parameterized database queries and the encoder or quoting mechanism made for the final context. This page handles JSON string escaping only.
Conversion and JSON checks run locally in the browser, which is useful when looking at private test data. Browser-local processing is not a substitute for good credential hygiene: remove tokens from bug reports, and take care when screen sharing or working on a shared computer.
JSON escaping questions
What does a JSON escape and unescape tool do?
It converts text to JSON string contents by representing quotes, backslashes, and control characters with JSON escape sequences. Unescaping reverses one or two such layers. The editor also checks whether the current text can be parsed as JSON, and can format or minify valid JSON.
Why are there three backslashes before a quote after Escape 2×?
The quote needs escaping, and the backslash added by the first pass must itself be escaped by the second. At two nested JSON string layers, three visible backslashes before a quote can be correct. Forward slashes in URLs are left as they are; they are not the backslashes used by JSON escaping.
Should I choose Escape 1× or Escape 2×?
Choose 1× when the JSON text will be stored as one string value. Choose 2× only when that already escaped value will be serialized into another JSON string. For decoding, use the number of layers you know are present and inspect the result after each pass when uncertain.
Does unescaping automatically turn the result into an object?
Unescaping restores characters; parsing is a separate operation. If the result is valid JSON, the editor identifies it and lets you format or minify it. Plain text stays plain text, even when it contains no JSON object.
Is my JSON uploaded when I use this page?
The conversion, parsing, formatting, and minifying are performed by JavaScript in your browser. File selection, copy, and download use browser features too. Avoid sharing a screen or saving a sample with secrets if other people can access that session.
Does JSON escaping make text safe for SQL, HTML, or shell commands?
No. JSON escaping only follows JSON string rules. SQL parameters, HTML output encoding, URLs, shells, and programming-language literals have different rules. Use the safe API or context-specific encoder for the place that will consume the value.
Related JSON terms
These are common names for the same practical tasks. Choose the one that describes the value you are handling, then check that the conversion depth matches its destination.
- JSON escape online
- JSON unescape
- escape JSON string
- double-escaped JSON
- decode JSON string
- JSON quote escaping
- JSON newline escape
- format escaped JSON
- JSON string converter
Related tools for your JSON workflow
Move from converting a string to inspecting, validating, or repairing the JSON it contains.
JSON Escape
Prepare JSON text for a string field or nested payload.
JSON Unescape
Turn escaped quotes and line breaks back into readable text.
JSON Viewer
Explore objects and arrays in a searchable tree.
JSON Fixer
Find and repair common JSON syntax problems.
JSON Schema Validator
Check whether JSON data matches a schema.
Related Articles
- How to Prettify JSON in Node.js: 5 Methods with Examples (2025)
Learn how to prettify, format, and beautify JSON in Node.js using JSON.stringify, fs module, Express middleware, third-party libraries, and online tools. Includes real code examples.
- How to Validate JSON: A Complete Developer's Guide (with Examples & Tools)
Learn how to validate JSON data using online tools, JavaScript, Python, and schema validators. Includes common JSON errors, JSON Schema basics, and best practices for developers.
- Advanced JSON Examples – Schema FAQ, API Errors, DynamoDB & MongoDB
Advanced JSON examples including Schema.org FAQ JSON-LD, API error responses, DynamoDB items, and MongoDB documents. Ideal for testing JSON Viewer and Formatter tools.
- Enterprise JSON Examples – OpenAPI, Webhooks, Kubernetes, Docker & Logs
Explore enterprise-grade JSON examples including OpenAPI schemas, webhook payloads, Kubernetes and Docker configs, and cloud log monitoring samples for JSON Viewer testing.
- Big JSON Sample Example – Large Nested JSON for Viewer & Formatter
Explore a big JSON sample with multiple lists, nested objects, and real-world data points. Perfect for testing JSON Viewer, JSON Formatter, and large API responses.