Escape and unescape JSON strings in your browser
To embed arbitrary text as a value in a JSON document, it has to become a valid JSON string literal — quoted, with every special character escaped. This tool turns raw text into that literal and decodes a literal back to plain text, so you can safely paste multi-line content into a JSON config, log line or API payload.
How it works
Escaping runs your text through the browser’s native JSON.stringify, which
escapes the special characters and wraps the whole value in double quotes.
Unescaping runs JSON.parse (adding the outer quotes first if you left them off),
turning the escapes back into the original characters.
| Character | Becomes |
|---|---|
" | \" |
\ | \\ |
| newline | \n |
| tab | \t |
| carriage return | \r |
| control / non-ASCII | \uXXXX |
The result is a complete literal including the surrounding quotes — unlike the companion JSON Escape tool, which returns only the body.
Example
Escaping this two-line text:
Path: C:\temp
Done
produces the literal:
"Path: C:\\temp\nDone"
Unescaping that literal restores the original two lines exactly. Everything runs locally in your browser — nothing is uploaded, which makes it safe for confidential text and snippets.
This tool vs the JSON Escape / Unescape tool
Both tools escape text for use in JSON, but they return different forms:
| Tool | Returns | Use when |
|---|---|---|
| JSON Escape / Unescape | The escaped body, without outer quotes | You are inserting the text into an existing JSON string in a document |
| This tool (JSON String Escape) | A complete JSON string literal, including outer double quotes | You need a standalone value you can paste directly as a JSON expression |
For example, escaping the text Say "hello":
- JSON Escape returns:
Say \"hello\"(body only) - This tool returns:
"Say \"hello\""(complete literal)
The complete literal is what you would paste as a value in a JSON document when writing the outer quotes yourself would be awkward — for example, when pasting into a query string, an API playground, or a command-line argument.
Practical use cases
Windows file paths in JSON. A path like C:\Users\Sam\Documents contains backslashes that must all be doubled in JSON. Pasting the path and clicking Escape gives you "C:\\Users\\Sam\\Documents" ready to paste.
Multi-line text as a single JSON value. A log entry, a code snippet, or a configuration template that spans multiple lines must have its newlines converted to \n. This tool does that in one step.
Generating test fixtures. When writing test files by hand, you often need to embed JSON strings-within-strings. Rather than manually counting and escaping backslashes, paste the inner JSON and escape it.
Safely sharing snippets over channels that mangle backslashes. Slack, Teams, and email clients sometimes eat or double backslashes. Unescape a received JSON literal here to recover the original text reliably.
What gets escaped (and what does not)
Characters that JSON requires to be escaped:
| Character | Escaped form |
|---|---|
Double quote " | \" |
Backslash \ | \\ |
| Newline | \n |
| Carriage return | \r |
| Tab | \t |
| Control characters (U+0000–U+001F) | \uXXXX |
Regular printable ASCII and most Unicode characters are included verbatim in the string — no escaping needed. Emoji and non-ASCII text round-trip correctly; the native serialiser may use \uXXXX sequences for some characters but unescaping resolves them back to the original code points.