JSON Escape/Unescape
Escape or unescape JSON strings to handle special characters
Input
Escaped JSON
What is JSON Escape/Unescape?
JSON strings can only contain a specific set of characters. The moment you try to put a literal double-quote, newline, or backslash inside one, you need to escape it — otherwise the parser breaks. JSON Escape does that conversion for you in both directions: take a raw human-readable string and turn it into a JSON-safe literal, or take an already-escaped string and recover the original.
The escape sequences themselves are defined in RFC 8259 §7: \" for quotes, \\ for backslashes, \n for newlines, \t for tabs, \uXXXX for arbitrary Unicode code points, and a handful of others. They're the same sequences JSON.stringify emits — this tool just exposes the conversion without a JavaScript console. For an end-to-end primer on JSON syntax, see the official JSON spec.
How to Use JSON Escape/Unescape
- Pick the Direction – Click the Escape/Unescape toggle to switch between converting raw text → JSON-safe string, or the reverse.
- Paste Your Input – Drop your text into the left editor. It can be a single line, a multi-line block, or already partially escaped — the tool figures it out.
- Read the Output – The right editor shows the converted result instantly. Special characters are replaced with their escape sequences (or vice versa).
- Copy the Result – Use the Copy button to put the converted string on your clipboard, ready to paste into a JSON file, an API request body, or a database column.
- Load a Sample – Click "Sample" to load a worked example with the most common escape sequences so you can see the transformation at a glance.
Pro Tip: If you need to embed a JSON object inside another JSON string (e.g., logging a payload to a JSON-formatted log line), escape the inner JSON once with this tool — that's enough. You don't need to escape it twice.
Example
An SMS template with quotes and a newline — the left shows the raw text you'd send to a logger, the right shows it correctly escaped so it can sit inside a JSON string.
Hi Ingrid, your "Unlimited 5G" plan renews on 2026-07-01. Reply STOP to opt out. Path: C:\Users\msg.txt
"Hi Ingrid,\nyour \"Unlimited 5G\" plan\nrenews on 2026-07-01.\nReply STOP to opt out.\nPath: C:\\Users\\msg.txt"Common Use Cases
Embedding JSON Inside JSON
Logging frameworks often expect each log entry to be a single JSON object — and one of the fields is, frustratingly, a JSON payload from somewhere else. Escape the inner JSON first so the outer object stays valid. Without escaping, every " inside the payload would close the outer string and the whole line would fail to parse.
Building API Request Bodies by Hand
When you're crafting a curl request or a test fixture and the body contains free-form text (an SMS template, a customer note, an HTML snippet), escape that text before dropping it into the JSON body. Quotes, newlines, and backslashes all need treatment — the MDN JSON guide has the full table.
Reading Escaped Strings From Logs
The opposite direction is equally common: you've pulled an entry out of a centralised log system and the payload is double-encoded, full of \" and \n. Unescape it once to recover the human-readable original, then run it through a JSON formatter if you need to inspect the structure.
Key Features
- Bidirectional – Escape and unescape with a single toggle, no separate tool needed.
- RFC 8259 Compliant – Handles all the escape sequences defined in the JSON spec, including
\uXXXXUnicode literals. - Multi-Line Support – Paste blocks of text containing newlines and tabs; they're converted correctly without splitting your input.
- Idempotent on Plain Text – Running escape on an already-clean string is a no-op. Safe to use even when you're unsure whether the input needs it.
- Browser-Only Processing – Nothing is uploaded; your strings stay on your device.
Frequently Asked Questions
Which characters actually need escaping in JSON?
Six characters require it: double quote, backslash, and four control characters — backspace, form feed, newline, carriage return, and tab (so technically five). On top of that, any code point below U+0020 must be escaped using \u notation. Everything else can appear literally, including Unicode letters and emoji. The authoritative list is in RFC 8259 §7.
What's the difference between escaping and JSON.stringify?
JSON.stringify serialises a whole JavaScript value (object, array, number, string) into a JSON document — it wraps strings in quotes and applies escaping. This tool just performs the escaping step on a raw string, with no surrounding quotes. Use stringify when you have an object; use this tool when you have a string that needs to live inside a JSON document.
Can I escape non-ASCII characters like emoji or accented letters?
Yes. By default JSON allows any UTF-8 character inside a string, so an emoji or an accented letter passes through unchanged. If you need ASCII-safe output (for compatibility with older systems), enable \u-escaping — every non-ASCII code point becomes \uXXXX. For background on Unicode and JSON, see the MDN stringify reference.
My escaped string still won't parse. What's wrong?
Usually one of three things: an unmatched quote (you escaped the opening but not the closing), a stray newline that wasn't escaped, or a backslash before a character that isn't a valid escape (e.g., \x). Run the suspect string through a JSON Validator to see exactly where parsing fails. Stack Overflow's JSON tag has thousands of solved cases for the trickier ones.
Is my data safe?
Yes. The escape and unescape conversions happen entirely in your browser. Nothing is sent over the network, nothing is cached, and nothing is logged.
Related Tools
- JSON Formatter – Pretty-print the unescaped result so you can read it.
- JSON Validator – Confirm the escaped output is valid JSON.
- JSON Minifier – Strip whitespace before escaping if you need the most compact possible literal.
- JSON to Table – View the unescaped JSON as a table to scan it quickly.
Useful Resources
- RFC 8259 §7 — Strings – Authoritative list of every JSON escape sequence.
- JSON.org – Original JSON spec with railroad diagrams for the string grammar.
- MDN — JSON.stringify – How JavaScript's built-in serialiser handles escaping, with examples.
- W3Schools JSON Syntax – Beginner-friendly walkthrough of JSON syntax rules.
- Stack Overflow JSON Tag – Solved cases for tricky escape and parsing problems.