JSON Escape & Unescape
Escape strings for use inside JSON, or unescape JSON string literals back to plain text. Handles quotes, newlines, tabs, and Unicode.
Last updated:
Paste text above to escape it for safe embedding inside a JSON string, or paste an escaped JSON string to unescape it back to plain text. Handles quotes, newlines, tabs, and Unicode.
What is JSON Escape?
JSON escaping converts raw text into a form that can live safely inside a JSON string literal — turning double quotes into \", newlines into \n, tabs into \t, and control characters into \uXXXX. You need this whenever you embed one JSON document inside another (stringified JSON), build JSON by hand, or store multi-line text in a JSON field. Unescaping does the reverse, revealing the original text.
How to escape or unescape a JSON string
- 1Choose Escape (text → JSON) or Unescape (JSON → text).
- 2Paste your content into the input pane.
- 3The tool applies the JSON string escaping rules and shows the result instantly.
- 4Copy the escaped/unescaped output for use in your payload or code.
Use Cases
Embed JSON inside JSON
Store a stringified JSON payload inside another JSON field (common in message queues and logs).
Hand-build JSON safely
Escape a multi-line string or code snippet so it can be dropped into a JSON value without breaking parsing.
Read escaped log lines
Unescape a \n- and \"-laden log field back into readable multi-line text.
Code Examples
Raw text
Line 1
He said "hi"Escaped for JSON
"Line 1\nHe said \"hi\""Key Concepts
- Escape sequences
- JSON defines shorthand escapes: \" \\ \/ \b \f \n \r \t, plus \uXXXX for any other character by code point.
- Control characters
- Characters U+0000–U+001F (like newline and tab) MUST be escaped in JSON strings; raw control characters make the JSON invalid.
- Double encoding
- Escaping already-escaped text produces \\n (a literal backslash-n), not a newline. Unescape once and verify to avoid this bug.
Tips & Best Practices
- ▸Escaping is not encryption — it only makes text safe inside JSON syntax, not private.
- ▸In real code, let JSON.stringify / json.dumps do the escaping. Hand-escaping is for quick fixes and debugging.
- ▸If you see \\n or \\" in output, the text was escaped twice — unescape one level.
- ▸The forward slash / may optionally be escaped as \/; both are valid JSON, but escaping it is rarely necessary.
Frequently Asked Questions
What characters need to be escaped in JSON?
The JSON specification requires escaping the double quote (\"), backslash (\\), and control characters (U+0000 through U+001F). Newline, carriage return, tab, backspace, and form-feed have shorthand escapes (\\n, \\r, \\t, \\b, \\f).
When would I need to escape a JSON string?
Typically when you need to embed a JSON string inside another JSON document (nested / stringified), or when generating JSON output without a library.
Related Tools
JSON Formatter
Format, beautify, and validate JSON online. Free, fast, and 100% local — your data never leaves your browser.
JSON Validator
Validate JSON online with instant error location and structure statistics (depth, keys, node types). 100% local — your JSON never leaves the browser.
JSONPath Tester
Test JSONPath expressions against sample JSON online. Get instant, highlighted results for queries like $.store.book[*].author.
JSON Diff
Compare two JSON documents structurally and see added, removed, and changed values by path. Handles nested objects, arrays, and type changes.
JSON → TypeScript
Convert JSON to TypeScript interfaces instantly. Generate strongly-typed TS types from any JSON sample.
JSON → Go
Convert JSON to Go structs online. Generates idiomatic Go structs with proper json tags and PascalCase field names.