JSON Escape / Unescape
Escape and unescape JSON strings - convert special characters to escape sequences
Input
Output
What Is JSON Escape?
You're storing JSON in a database column as a string, or you've got an API response that came back double-escaped and you need to un-mangle it. That's the everyday reality that makes a JSON escape tool genuinely useful. In JSON strings, certain characters must be escaped: double quotes become \", backslashes become \\, newlines become \n, tabs become \t. The full list is in RFC 8259 Section 7. Unescaping reverses the process — turning those sequences back into real characters.
This tool has two modes: Escape and Unescape. Toggle between them at the top. Both run in your browser; nothing is sent to a server.
How to Use This Tool
Choose Mode
Select Escape to convert special characters to escape sequences, or Unescape to convert them back.
Paste Input
Paste your text into the left editor. You can paste a raw string, a JSON string value, or a full JSON document. Use Sample or Upload if needed.
Copy Result
The right panel updates automatically. Use Copy or Download to get the result. For parsing escaped JSON strings into objects, try String to JSON.
JSON Escape Examples
Escaping converts special characters to escape sequences. Telecom-themed example:
Raw input (with newline)
Escaped output
When Escaping Matters
When you embed a JSON string inside another JSON string, or when you store JSON in a database field that expects a string, escaping ensures the inner quotes and backslashes don't break the structure. When building JSON programmatically, JSON.stringify() handles escaping automatically. This tool is for manual editing or when you're working with pre-escaped strings from logs or APIs.
Unescaping is useful when you receive a double-escaped string (e.g. from an API that returns JSON as a string) and need to get the actual JSON. The String to JSON tool can parse escaped strings directly.
Frequently Asked Questions
What characters need to be escaped in a JSON string?
Per RFC 8259: double quote " → \", backslash \ → \\, newline → \n, tab → \t, carriage return → \r, and control characters (U+0000–U+001F) → \uXXXX. Everything else can be included literally.
How do I unescape a JSON string in JavaScript?
Use JSON.parse() if the string is a valid JSON value (e.g. JSON.parse('"\\"hello\\""'))). For raw escape sequences outside of a JSON context, a replace-based approach works. This tool handles both cases without writing code.
When would I need to unescape JSON?
When an API returns JSON that's been wrapped in a string (double-encoded), or when JSON is stored in a database column as an escaped string. Unescaping removes the outer layer so you can parse the inner JSON.
Does JSON.stringify() automatically escape strings?
Yes — JSON.stringify() handles all necessary escaping automatically when building JSON programmatically. This tool is for manual editing, log inspection, or when you receive pre-escaped strings you need to work with directly.
Is my data sent to a server?
No. All processing runs in your browser. Nothing is ever uploaded.
Related Tools
The JSON string escaping rules are in RFC 8259. MDN covers JSON in JavaScript. The JSON specification defines all escape sequences. For parsing, see JSON.parse() and JSON.stringify(). The jq tool handles JSON from the command line.