Input

Escaped JSON

The escaped literal appears here

Paste any text in the panel on the left and it is escaped as you type, quotes included.

Success
Warning

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 — because that is literally what runs when you type here, quotes and all.

How to Use JSON Escape/Unescape

  1. Pick the Direction – Click the Escape/Unescape toggle to switch between converting raw text → JSON-safe string, or the reverse.
  2. Paste Your Input – Drop your text into the left editor — a single line or a multi-line block, both work. In escape mode every character is taken literally, so an input that is already escaped gets escaped a second time: paste \n and you get back \\n, because a backslash is just a character that needs escaping. Nothing here detects a previous pass for you.
  3. Read the Output – The right editor shows the converted result instantly, and in escape mode it includes the opening and closing double quotes — what you are looking at is a complete JSON string literal, ready to drop straight into a document.
  4. 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.
  5. 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 two quoted words, four line breaks and a Windows path. On the right is what escape returns for it, byte for byte: the newlines have folded into \n, each " has become \", each \ in C:\Users has doubled — and note the quote characters at both ends. Those are part of the output. 103 bytes of text come back as a 113-byte literal you can paste after a colon and parse straight away.

Raw string → Escaped Escape
Raw text5 lines · 103 B
Hi Ingrid,
your "Unlimited 5G" plan
renews on 2026-07-01.
Reply STOP to opt out.
Path: C:\Users\msg.txt
JSON string literal1 line · 113 B · quotes included
"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. Copy the whole field value — including its surrounding quotes, which is the step people skip — flip the toggle to Unescape and paste. Without the outer quotes the input is not a JSON string literal and the parse fails on the first brace. With them you get the original payload back, ready for the JSON Formatter.

Key Features

  • Bidirectional – Escape and unescape with a single toggle, no separate tool needed. Toggling also swaps the two panes, so you can send a result straight back through the other direction to check it round-trips.
  • Quotes included – Escape emits a complete JSON string literal, opening and closing quotes and all. Paste it after a colon and the document is valid; if you only wanted the interior, delete the two outer characters.
  • Unescape reads every sequence in the spec – The reverse direction is a real JSON parse, so \n, \t, \", \\, \/ and \uXXXX all resolve exactly as RFC 8259 §7 defines them, including surrogate pairs.
  • Multi-Line Support – Paste blocks of text containing newlines and tabs; they're folded into \n and \t on one line rather than splitting your input.
  • Escaping is not idempotent — and that is correct – Run escape twice and you get "\"abc\"", not "abc". The second pass has a quoted literal as its input and escapes that faithfully. Escape once, check the output, and stop.
  • 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?

Honestly: none. The escape direction is a one-line call to JSON.stringify on whatever text is in the left pane, which is why the output carries its opening and closing quotes — that is a whole JSON string literal, exactly what stringify produces for a string. So the value here is not a different algorithm, it is not having to open a console, paste a multi-line block into it without the newlines mangling the input, and read the result back out. The reverse direction is the matching JSON.parse, which is why unescape wants the outer quotes on its input too.

Can I escape emoji or accented letters?

They pass straight through. JSON strings are Unicode, so Ingrid Hallström and a 📶 stay exactly as typed — no \uXXXX is produced, and none is needed, because the document is UTF-8. There is no ASCII-only switch on this page; if some downstream system genuinely requires pure ASCII, that is a job for the encoder in your own code (Python's json.dumps does it by default with ensure_ascii). Going the other way, \uXXXX in your input is decoded normally, so a payload that arrived ASCII-escaped comes back readable.

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 the JSON Validator to see exactly where parsing fails — it reports a line and column, which beats staring at the literal.

Unescape says "Nothing to unescape". What did I paste?

Something that parses as JSON but is not a string — most often a whole document, {"msisdn": "447700900142"}, pasted into the unescape side. There are no escape sequences in it to undo, so there is nothing this direction can return; open it in the JSON Formatter instead. The input unescape actually wants is a quoted literal with its outer quotes intact, like "{\"msisdn\": \"447700900142\"}" — which is exactly what you get if you copy a field value out of a log line rather than the field's contents.

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

Useful Resources

  • JSON.org – The original spec, with a railroad diagram for the string grammar worth one look.
  • MDN — JSON.parse – What the unescape direction runs, including how it reports a failure position.
  • Stack Overflow JSON Tag – Solved cases for the escaping problems that survive a first look.