JSON / String Escape & Unescape
FREE TOOL · NO SIGN-UP
This JSON escape unescape tool makes any text safe to use inside a JSON string, and turns escaped JSON strings back into readable text. Paste your text, choose escape or unescape, and the converted result appears instantly, ready to copy into your code, API request or config file. It’s built for developers, QA testers and anyone wrestling with backslashes in a JSON payload.
What JSON Escaping Does
JSON strings sit between double quotes. Some characters inside them would confuse a parser, so the JSON standard (RFC 8259) requires them to be written as escape sequences that start with a backslash.
Required escape sequences
Two characters must always be escaped: the double quote becomes \" and the backslash becomes \\. Control characters also need escaping, because they can’t appear raw inside a string. The common ones have short forms: a newline is \n, a carriage return \r, a tab \t, plus \b for backspace and \f for form feed. Other control characters use the \u form with four hex digits.
When you escape text with this tool, it uses the browser’s own JSON.stringify, so the output follows the standard exactly. A multi-line paragraph with quotes becomes a single line with \n and \" in the right places.
Unicode escapes
Any character can also be written as \u followed by its four-digit hex code, for example \u00e9 for é. JSON allows raw Unicode in UTF-8, so escaping accented letters or emoji isn’t required, and this tool leaves them as they are when escaping. When unescaping, it decodes every \uXXXX sequence back into the real character, including emoji stored as surrogate pairs.
How to Escape or Unescape JSON
Results update live as you type.
Step 1 – Paste text
Paste the text into the Input text box. For escaping, that’s plain text: a message, HTML snippet, SQL query or multi-line block. For unescaping, it’s an escaped string, with or without the surrounding double quotes.
Step 2 – Choose escape or unescape
Pick Escape text → JSON string or Unescape JSON string → text from the Mode menu. In escape mode, tick Wrap in double quotes if you want the output ready to paste as a complete JSON value, for example "Hello \"world\"".
Step 3 – Check the output
The result appears in the output panel, with input and output character counts. If the input can’t be unescaped, for example because of a broken escape sequence, you’ll see an error message explaining what went wrong instead of a half-converted result.
Step 4 – Copy into your code
Click Copy and paste the string where you need it, or Download to save it as a text file. Clear resets the tool.
Double-Escaped and Stringified JSON
JSON inside JSON
Sometimes a whole JSON object is stored as a string value inside another JSON document. Logging systems, message queues, webhooks and some databases do this. The inner object’s quotes are escaped, so you see something like "{\"id\":1,\"name\":\"Ana\"}". That’s called stringified JSON. To read it, unescape it once and you’ll get the inner object back as normal JSON, which you can then pretty-print with our JSON Formatter & Minifier.
Fixing backslash chains
If you see long runs like \\\", the data has been escaped more than once. Each layer of escaping doubles the backslashes. Unescape the string, check the result, and unescape again if it still contains escaped quotes. Stop when you reach readable text or valid JSON. Then fix the code that escapes it twice, otherwise the problem comes back.
Escaping in Code
JSON.stringify and json.dumps
In real code, let your language’s JSON library handle escaping. In JavaScript, JSON.stringify(value) escapes strings correctly and JSON.parse(text) reverses it. In Python, use json.dumps() and json.loads(). PHP has json_encode() and json_decode(). These functions cover every edge case and are the reason most developers rarely escape JSON by hand. An online tool is for checking, debugging and one-off jobs.
Never building JSON by concatenation
Building JSON by joining strings, like '{"name":"' + name + '"}', breaks as soon as the value contains a quote, backslash or newline. Worse, it can let user input change the structure of your data. Always build an object and serialise it with a JSON library.
JSON vs HTML vs URL Escaping
Different rules
Each format has its own escaping rules. JSON uses backslashes (\"), HTML uses entities (") and URLs use percent-encoding (%22). Using the wrong one produces broken output. For HTML, use our HTML Entity Encoder / Decoder.
Embedding JSON in HTML script tags
When you place JSON inside a <script> tag, as with JSON-LD structured data, a string containing </script> would end the tag early. Escaping the forward slash as <\/ prevents that. The schema generators on FHSEO Hub do this automatically.
JSON Escaping Mistakes
Single quotes
JSON only allows double quotes around strings and keys. {'name': 'Ana'} is valid in JavaScript or Python, but not in JSON.
Raw newlines
A literal line break inside a JSON string is invalid. It has to be written as \n. Escaping a multi-line text block with this tool takes care of that.
Escaping twice
Escaping text that’s already escaped turns \" into \\\". Escape once, right before the value goes into JSON.
Ship Payloads That Parse First Time
Escaping errors are small but they break whole requests. Use the JSON escape unescape tool to check strings before they go into code, then format full payloads with the JSON Formatter & Minifier, escape markup with the HTML Entity Encoder / Decoder and generate test IDs with the UUID / GUID Generator. See every free tool in the FHSEO Hub free SEO tools collection.
