JSON Escape / Unescape
Escape text into a JSON string or unescape a JSON string back to text.
Escape text for a JSON string—and reverse it exactly
Convert quotes, backslashes, tabs, line breaks and control characters into JSON string escapes, or decode a valid escaped string body back to text.
Escape text
mode
24 B
input size
29 B
output size
Raw text
24 charactersEscaped string body
29 charactersThe escaped result is a JSON string body, not a complete JSON document with surrounding quotes.
About the JSON Escape / Unescape
When you embed text inside a JSON string, special characters like quotes, backslashes, newlines and tabs must be escaped, or the JSON becomes invalid.
This tool escapes any text into a safe JSON string body, and unescapes an escaped string back into the original text.
It runs entirely in your browser, so your data stays private.
Key features
- Escape text to a JSON string body
- Unescape back to raw text
- Handles quotes, newlines, tabs and unicode
- Explicit invalid escape-sequence errors
- Copy, download or reuse the result
- Local, private processing
How to use
- 1Choose Escape or Unescape.
- 2Paste your text or load the realistic sample.
- 3Review any invalid escaped-string error.
- 4Copy, download or reuse the result as input.
Examples
Line 1\nLine 2Line 1\\nLine 2The newline becomes \n so the text is safe inside a JSON string.
Frequently asked questions
- What characters get escaped?
- Double quotes, backslashes and control characters such as newlines and tabs become their escape sequences (\", \\, \n, \t), so the result is a valid JSON string body.
- Does it add the surrounding quotes?
- No. It returns the escaped body without the outer quotes, so you can drop it straight into a JSON string.
- Why does unescape show an error?
- If the input is not a valid escaped string (for example a stray backslash), it cannot be parsed. Fix the escape sequences and try again.
Helpful guides
Continue your workflow
Open a related tool to prepare your files or refine the finished result.
- Featured toolDeveloper ToolsJSON Formatter
Format, validate and minify JSON instantly.
Open tool - Featured toolDeveloper ToolscURL to Code Converter
Convert a curl command into JavaScript fetch, axios or Python requests code.
Open tool - Featured toolDeveloper ToolsHTML Entity Encoder / Decoder
Escape text to HTML entities or decode entities back to characters.
Open tool
