JSON Escape and Unescape
This tool switches between two jobs with a toggle. Escape turns raw text into the inner body of a JSON string, doubling backslashes, protecting quotes and converting control characters into short escapes like backslash n and backslash t. Unescape reverses the process, decoding those sequences plus backslash uXXXX back into the characters they represent.
How to escape or unescape JSON
- Choose Escape to make text JSON-safe, or Unescape to decode an escaped string.
- Paste or type into the input box on the left.
- Watch the result update instantly in the read-only output box.
- Check the character count shown above the output if size matters.
- Click Copy to put the result on your clipboard.
Examples
Escape a Windows path with quotes
Path: "C:\Temp"
Path: \"C:\\Temp\"
Escape a newline and a tab
Name: Ada Role: Engineer
Name:\tAda\nRole:\tEngineer
Unescape a string back to plain text
She replied:\n\t\"done\"
She replied: "done"
Frequently asked questions
Does the output include the surrounding quotes?
No. Escape returns only the inner string body, so you place it between your own double quotes when building a JSON value. Likewise, unescape expects the body without the outer quotes and decodes what is inside.
Which characters get escaped?
Backslash and double quote are protected, and backspace, form feed, newline, carriage return and tab use their short forms backslash b, f, n, r and t. Any other control character below U+0020 becomes a backslash uXXXX sequence. Printable letters, digits, punctuation and unicode above that range pass through unchanged.
Why is the forward slash left alone when escaping?
JSON allows a forward slash either plain or as backslash slash, and both are valid. This tool leaves it plain when escaping for readability, but unescape still accepts backslash slash and decodes it back to a slash.
What happens with an invalid escape when unescaping?
It stops and shows an error rather than guessing. A lone trailing backslash, an unknown letter after a backslash, or a backslash u sequence without four hex digits are all rejected so you can fix the source.
Does it handle backslash uXXXX unicode escapes?
Yes, on the unescape side. A four hex digit escape such as backslash u00e9 decodes to its character. On the escape side, printable unicode is kept as the literal character rather than expanded into an escape.
Can I use this to escape a whole JSON document?
It escapes the text you paste as one string literal, which is exactly what you want when embedding a JSON blob inside another JSON string. It does not validate or reformat JSON structure; use a JSON formatter for that.
Is there a length limit?
There is no fixed cap. Processing happens in your browser, so the practical limit is your device memory, and even long strings escape or decode almost instantly.
What is the difference between this and URL encoding?
JSON escaping protects characters that would break a JSON string, mainly quotes, backslashes and control codes. URL encoding uses percent codes to make text safe inside a web address, a different character set and syntax. Reach for the URL encoder when the target is a link.
Is my text private?
Yes. Everything runs locally in your browser and nothing is uploaded to a server, so sensitive strings never leave your device.
Learn more
- How JSON string escaping works
The rules behind JSON string literals: which characters must be escaped, the short escapes, backslash uXXXX, and how to embed JSON inside JSON safely.
Related tools
URL Encoder
Encode or decode URLs and query strings online. Percent-encode a value, escape a full URL, or decode back to plain text. Free, fast and private.
CSV to Markdown
Convert CSV data into a clean GitHub-flavored Markdown table. Handles quoted fields, commas, and pipes, with column alignment. Free, fast and private.
.env to JSON
Convert a .env file to JSON, or JSON back to .env. Parses KEY=value lines, comments, quotes and export. Runs entirely in your browser.
ASCII Table
Full ASCII table for all 128 codes with decimal, hex, octal and binary values, character names and descriptions. Search by code, hex or character.
Aspect Ratio Box Generator
Generate CSS for a responsive aspect-ratio container. Use the modern aspect-ratio property or the padding-top fallback, then copy the ready code.
Aspect Ratio Calculator
Calculate aspect ratios fast. Enter a ratio like 16:9 and one dimension to get the other, or enter width and height to simplify the ratio.