Skip to content

JSON Escape / Unescape

Escape text for safe use inside JSON strings, or decode escaped JSON back to plain text

0 lines · 0 characters

Escape and Unescape JSON Strings Reliably

JSON has exactly one string syntax, and hand-editing rarely gets it right: a stray quote breaks the document, a real newline is illegal inside a string, a Windows path full of backslashes turns into escape-sequence soup. This free tool converts in both directions. Escape mode takes plain text — multi-line content, quotes, tabs, special characters — and produces a string safe to drop between quotes in any JSON document. Unescape mode reverses the process, turning \n, \", \\, \t, and \uXXXX sequences back into the readable text they encode. Both directions use the same parsing rules as JSON itself, and everything runs in your browser.

What Escaping Changes

JSON strings may not contain raw double quotes, backslashes, or control characters, so escaping replaces each with its sequence: quotes become \", backslashes become \\, newlines \n, carriage returns \r, tabs \t, and other control characters become \u escapes like \u0001. Ordinary letters, digits, punctuation, and Unicode text pass through unchanged — escaping touches only what JSON forbids. The output is the exact content of a valid JSON string; enable the wrapping option to receive it with surrounding quotes, ready to paste as a complete value.

When You Need Escape Mode

Escape mode earns its keep wherever JSON is written by hand or assembled from text. Embedding an error message, SQL query, or HTML fragment into a config file or API request body. Building test fixtures that contain multi-line strings. Pasting a file path like C:\\Users\\name into a settings file. Putting a JSON document inside another JSON document — a common and confusing case where the inner document must be escaped wholesale. In each case the tool guarantees the result parses, eliminating the quote-counting that manual escaping demands.

When You Need Unescape Mode

Escaped strings are unreadable in proportion to how interesting they are: log entries arrive with payloads full of \n and \", API responses nest JSON inside JSON, and debugging means squinting through backslashes. Unescape mode decodes the sequences back to real characters — newlines become actual line breaks, \u00e9 becomes é — turning a wall of escapes into the original text. Paste the string with or without its surrounding quotes; the tool handles both and reports invalid escape sequences instead of guessing.

Double Escaping and How to Avoid It

The classic failure mode is escaping twice: text that already contains \n gets escaped again into \\n, and the consumer displays a literal backslash-n instead of a line break. It happens when two layers each escape — application code plus a templating system, or JSON embedded in JSON where the wrong layer was escaped. The symmetric design of this tool helps diagnose it: unescape once and inspect; if the text is still full of sequences, it was double escaped and one more unescape recovers the original. Escape exactly as many times as there are JSON layers, no more.

Edge Cases the Tool Handles

Forward slashes are left unescaped, since JSON permits both forms and bare slashes are more readable. Unicode beyond ASCII passes through as-is rather than being converted to \u sequences, keeping non-English text legible while remaining valid JSON. In unescape mode, surrounding quotes are detected and stripped automatically, and malformed input — an unterminated escape, a bad \u block — produces a clear error rather than corrupted output. The result of each mode is always valid input for the other, so round trips are lossless.

Privacy and Client-Side Processing

All conversion runs locally in your browser; payloads, logs, and config fragments are never uploaded, stored, or logged anywhere. That matters here more than for most tools, since escaped strings often contain API responses and internal data. The text is cleared from memory when you close the page, and the output statistics show the resulting length in characters.

$ faq

How do I escape text for JSON?
Paste the plain text, choose Escape mode, and click Convert. Quotes, backslashes, newlines, tabs, and control characters are replaced with their JSON escape sequences, producing a string that is safe to place between quotes in any JSON document.
How do I decode an escaped JSON string?
Choose Unescape mode and paste the string — with or without its surrounding quotes. Sequences like \n, \", \\, \t, and \uXXXX are converted back to the characters they encode, restoring the original readable text.
Which characters does escaping change?
Double quotes, backslashes, and control characters: quotes become \", backslashes \\, newlines \n, carriage returns \r, tabs \t, and remaining control characters become \u sequences. Ordinary text and non-English Unicode pass through unchanged.
What is double escaping and why is my output full of \\n?
Double escaping means the text was escaped twice, turning \n into \\n, and consumers then display a literal backslash-n. Unescape once to check: if sequences remain, unescape again to recover the original, and fix the pipeline so only one layer escapes.
Can I escape a whole JSON document to embed it in another?
Yes. Paste the inner document as plain text and escape it; the result is a single JSON string containing the document, ready to use as a value. Unescaping that value later returns the original document exactly.
What happens if my escaped string is invalid?
Unescape mode validates as it parses. An unterminated escape or malformed \u sequence produces a clear error message instead of silently corrupted output, so you know the input needs fixing.
Is my data uploaded during conversion?
No. Escaping and unescaping run client-side in your browser; payloads and logs never leave your device and are cleared from memory when the page closes.