Choose the right operation for JSON text and string escaping
This page groups four related string operations: escape raw text, unescape a JSON string, stringify a whole JSON document, and reverse that stringification. Choose the operation based on whether your input is text or JSON.
When should you use it?
- Put a quote or newline inside a JSON string.
- Read an escaped string from a log.
- Embed a JSON document as the value of another JSON field.
Example: escape a quoted string
The surrounding quotes and backslashes make the text a valid JSON string.
Hello "JSON""Hello \"JSON\""Identify the layer you are encoding
Escaping turns ordinary text into a quoted JSON string. Stringifying a document adds a string layer around JSON that is already valid. They solve different problems: a message containing a newline can be escaped as text, while an API field containing a complete JSON document needs the document encoded as one string value. Check what the receiving field actually expects.
Remove exactly the layer that was added
Unescape returns the plain text inside one quoted JSON string. Unstringify also requires that the decoded text is valid JSON. A backslash in the editor may be part of the source encoding rather than part of the final text. Read the before-and-after example before repeatedly applying the operation; repeated encoding can produce another layer of quotes and backslashes each time.
Put quotes and backslashes in the right place.
A JSON string literal wraps text in quotes and escapes reserved characters. A stringified JSON document contains an entire JSON text inside that string.
Choose the operation
Escape raw text, unescape a JSON string, stringify JSON, or reverse a stringified document.
Paste the input
The tool validates quoted strings and JSON documents before decoding them.
Copy the exact result
Use the output as text or JSON according to the selected operation.
When should I escape text instead of stringify a JSON object?
Escape treats its input as arbitrary text and produces one quoted JSON string. Stringify first requires a valid JSON document, then stores that entire document text inside a string. Choose based on the type of input you have, not the output’s appearance.
Two different quoted results
textEscape raw text: Hello "JSON" → "Hello \"JSON\""
Stringify document: {"a":1} → "{\"a\":1}"The second result decodes to a complete JSON document. The first decodes to ordinary text.
What does unescape return compared with unstringify?
Unescape returns the plain text in any valid JSON string. Unstringify also requires that decoded text to be valid JSON and returns a readable JSON document.
What should you check before using the result?
Escaping does not validate the raw text as a JSON document. Unstringify does validate the inner document. Use the focused pages for a single operation.
Escape versus stringify
Escaping treats any input as text. Stringifying a document first verifies that the input is valid JSON, then wraps that entire source text as one JSON string. It preserves whitespace and numeric spelling inside the string.
Unescape versus unstringify
Unescape returns plain text from a quoted JSON string. Unstringify additionally requires the decoded text to be valid JSON and presents a readable copy. Neither operation executes code or repairs invalid JSON.
Technical reference: JSON syntax and interoperability · RFC 8259