What JSON Escape does, and when you need it
JSON Escape turns any text into a string that can go between the quotes of a JSON value: every double quote becomes \", every backslash \\, every line break \n and every tab \t. Choose Unescape a JSON string to go back, and the codes become the characters they stand for. The result appears in the second box as you type, ready to copy or download.
It writes what JSON's own rules ask for, the same as a browser's JSON tools do, without the quotes around it, so you can paste it between your own. It runs in your browser: your text is never uploaded and never saved, so closing the page forgets it.
Some jobs it is made for:
- Putting a message or a template into a JSON file, with its quotes and line breaks kept.
- Writing a request body for an API test, with text that has quotes in it.
- A Windows path in a configuration file, where every backslash must be doubled.
- Reading a string from a log or an API reply, full of \n and \" codes, as plain text.
- Strings in code that follows JSON's rules, as JavaScript's double-quoted strings do.
Step by step: escaping and unescaping
It takes a few seconds, and the same steps work on a phone and on a computer:
- Choose the way under Do: Escape text for a JSON string, or Unescape a JSON string.
- Type or paste in the top box, or choose Open a text file, or drop a file anywhere on the page.
- Read the result. If a string can't be unescaped, the page says: "This can't be read as a JSON string: check its backslashes."
- Copy or download the result, and paste it between the quotes of your JSON value.
Press Try a sample: the box fills with two lines, He said "hi", a tab, and left., and Path: C:\files\new. The result is one line: He said \"hi\"\tand left.\nPath: C:\\files\\new. Choose Unescape a JSON string and paste it back, and the two lines return.
What is escaped, exactly
The rules are JSON's own (RFC 8259), the same as JavaScript's JSON.stringify writes. They are written here in full, and checked by our tests.
| Character | Written as | Example |
|---|---|---|
| Double quote | \" | "hi" becomes \"hi\" |
| Backslash | \\ | C:\new becomes C:\\new |
| Line break | \n | Two lines become one line with \n between them |
| Tab | \t | tab, a tab, here becomes tab\there |
| Carriage return, backspace, form feed | \r, \b and \f | As JSON's short escapes |
| Other control characters | \u and four hex digits | The character 1 becomes \u0001 |
| Everything else | As it is: letters of every script, ₹, emoji, the slash and the apostrophe | é ₹ 😀 / stay the same |
Escaping and then unescaping gives back the text you started with: our tests check that on texts with quotes, tabs, line breaks, Windows paths, accents, ₹ and control characters.
Real results from our tests
We tested JSON Escape with headless Chromium 148, the open-source browser Chrome is built on, on a Windows laptop with an Intel Core i7-1185G7 and 32 GB of memory, on 1 November 2026. Other work was running on the laptop at the same time, so times vary from run to run: each time below is the middle one of 3 runs.
Escaping is quick. It took 3 milliseconds or less to escape 500,000 characters of English, Hindi or a mix of English, Hindi, Tamil and emoji for a JSON string, the most the page takes at once.
After a text is put in the box, the page waits 0.15 second before it works, so a burst of typing is worked on once, and 0.4 second when the text has more than 400,000 characters. So the result of 500,000 characters of English showed between 0.43 and 0.44 second after it was put in the box in our test. A result of more than 100,000 characters shows only its first 100,000 in the box, and says so, because showing a very long text is slow for the browser; Copy and Download take all of it.
Checked by our tests. Every example on this page is one of our tests, run on the page's own code. They cover quotes, backslashes, line breaks, tabs and control characters, Windows paths, letters of other scripts and emoji left as they are, every escape JSON allows when unescaping, strings with and without their quotes, broken escapes, and escaping and unescaping back to the start.
Size and offline. On a first visit the page downloads about 0.1 MB for the tool: the page, its styles, its scripts and the fonts, with Google's ad code not counted. In our test we switched the network off after the page had loaded and pressed Try a sample: the result showed 0.1 seconds later or less in each of 15 runs.
Phone-sized screen. We also ran the tests on a phone-sized screen in headless Chromium (390 × 844 pixels, with touch). That is not a real phone. Every button, box and tick box was 44 pixels high or more, and the page did not scroll sideways. These tests don't cover Safari or Firefox.
Try it yourself: press "Try a sample" at the top of this page. It puts two lines in the box, with quotes, a tab and a Windows path. The result is one line, with \"hi\", \t, \n and the path's backslashes doubled. Then choose Unescape a JSON string and paste it back.
Try the sampleUnescaping a string
Unescape reads every escape JSON allows: \", \\, \/, \n, \t, \r, \b, \f and \u with four hex digits, including the two halves of an emoji: \ud83d\ude00 becomes 😀, and \u20b9 becomes ₹.
You can paste the string with its quotes around it or without them: "already quoted\n" gives already quoted and a line break. A double quote inside that wasn't escaped is accepted too, so say "hi" \n gives say "hi" and a line break.
A backslash followed by anything else, such as \x or a lone \ at the end, is not a JSON escape, and the page says: "This can't be read as a JSON string: check its backslashes." Single quotes are not JSON's, so 'single' stays as it is.
A typical case is an error message in a log: File not found:\nC:\\data\\report.csv. Unescaped, it reads as two lines, File not found: and C:\data\report.csv, with single backslashes, as the program meant it. You can copy the string from between its quotes, or with them: both work.
Windows paths, quotes and code
Windows paths are the commonest trouble. A path such as C:\Users\Ram\Documents in a JSON file must be written C:\\Users\\Ram\\Documents, because a single backslash starts an escape: \U is not a JSON escape, and \n in C:\new would be read as a line break. Escape the path here and paste it. A forward slash, C:/Users/Ram, also works in many programs and needs no escaping.
Quotes inside text end a JSON string early unless they are escaped. A message such as He said "hi" becomes He said \"hi\". An apostrophe needs nothing: Ram's stays as it is.
Code. JavaScript's double-quoted strings follow the same rules, so the result works there too. Other languages differ in small ways, such as which characters they let through as they are; check your language's rules for anything unusual. For a whole JSON document rather than one string, use JSON Formatter, which checks and lays out the full structure.
A worked example
Say a message for an app's settings file must read, on two lines, Dear Ravi, and Your "order" is ready. Typed straight into JSON, the line break and the quotes would break the file. Escape the two lines here and the result is one line:
Dear Ravi,\nYour \"order\" is ready.
Paste it between the quotes of the value, and the file reads {"message": "Dear Ravi,\nYour \"order\" is ready."}. A JSON reader, such as a browser's JSON.parse, gives back the two lines exactly as you wrote them, with the quotes around order. To check a file like this as a whole, paste it into JSON Formatter: it says at once whether every string is closed and every escape is right.
Everyday uses
- A message template in a JSON file: write the message with its line breaks, escape it, and paste it between the value's quotes.
- An API test: escape the text for a request body, so quotes in it don't break the JSON.
- Read a log line: unescape a string full of \n codes to see its lines.
- Configuration paths: escape a Windows path once, correctly.
- Other formats: HTML Entities Encoder for HTML, URL Encode for web addresses.
Opening a text file
Choose Open a text file, or drop a file anywhere on the page, and the tool reads it on your device. These files open: .txt, .md, .csv, .tsv, .log, .json, .xml, .srt, .vtt, .html and other plain-text files, with up to 500,000 characters. The file's name and size appear below the box with an x; press the x to remove the file's text. The file is read on your device and never uploaded. The result can be copied, or saved as a new text file; the file you opened is never changed.
- Letters. A file saved as UTF-8 (a byte order mark at the start is dropped) or as UTF-16 with a mark is read correctly, Hindi and Tamil included. A file that is not valid UTF-8 is read as Windows-1252, and the page says so: "This file isn't saved as UTF-8, so it was read as Windows-1252. If letters look wrong, save it as UTF-8 and add it again."
- Windows line breaks. A Windows file stores each line break as two characters. The tool reads the pair as one line break, so a line break is written as \n, as JSON wants.
- Several files. Only the first one opens, and the page says so, for example "Opening a.txt only. Open the others one at a time."
- Not a text file. A Word, PDF or picture file renamed to .txt is not read, and the page says it doesn't look like a text file. A file named .docx, .pdf or .rtf gets this message: "Only text files (.txt and similar) can be opened here. For a Word or PDF file, copy its text and paste it into the box."
- Empty or too long. An empty file says it is empty. A file with more than 500,000 characters is not opened, and the page says how many characters it has.
For a Word or PDF file, open it in the program you normally use, select the text, copy it, and paste it into the box. A PDF whose pages are scans holds pictures, not text, so there is nothing to copy.
Private: your text stays on your device
Your text never leaves your device. The tool runs inside your browser and has no upload step: it never sends the text you type, paste or open anywhere, and it keeps no copy of it, so closing the page forgets it. The page's Content Security Policy lets it contact only this site and Google's ad service, which pays for the site; our code never gives your text to the ad code. You can check it yourself in your browser's network panel (F12 on a computer): escaping and unescaping adds no request that carries your text. The site's menu does remember the last few tools you opened, on your device.
Strings for JSON often hold private things: API messages, configuration, paths on your computer, test data with real names. This tool escapes them without handing them over. Our privacy policy says what we collect, and How we prove it shows how you can check our claims yourself.
Once the page has loaded, it also works with the internet switched off. In our test we switched the network off after the page had loaded and pressed Try a sample, and the result showed 0.1 seconds later or less in each of 15 runs.
Long texts
The tool takes up to 500,000 characters at once, about 500 KB of English text. What happens when a text is longer:
- A paste that would go over the limit is not added. This holds for Ctrl+V, for press and hold, and for the Paste button. The page says, for example: "That text is very long (550,000 characters), so it was not added. The box can hold 500,000 characters. Split it into smaller parts for faster results."
- A file with too many characters is not opened. The page says, for example: "long.txt has 550,000 characters, more than the 500,000 counted at once. Split it into smaller parts for faster results."
- A text that gets in some other way stays, unchanged. If text is dragged into the box, for example, it stays there, the result stays empty and the note says: "This text is very long (550,000 characters). Split it into smaller parts for faster results."
Escaping is quick. In our tests it took 3 milliseconds or less to escape 500,000 characters of English, Hindi or a mix of English, Hindi, Tamil and emoji for a JSON string. The slow part is the browser showing a very long text in a box, so a result of more than 100,000 characters shows only its first 100,000, without cutting an emoji in half, and the note says so, for example "Showing the first 100,000 of 164,999 characters. Copy and Download take all of it." Copy and Download always take the whole result.
Tips
- Escape the text only, not the quotes around the value: the result goes between your own quotes.
- Escape once. Escaping an escaped string doubles every backslash again.
- Unescape to check: going back gives your text, so you can see the result is right.
- Use forward slashes in paths where the program accepts them.
- Check a whole document with JSON Formatter after pasting the string in.
- Keep your own copy. The page forgets everything when you close it.
Limits
- One string at a time. It escapes text for one JSON value; it doesn't build or check a whole JSON document.
- Letters stay as they are. é, Hindi and emoji are not written as \u codes, which JSON allows; some old systems want them as codes.
- JSON's rules only. Other formats and languages escape in their own ways.
- Single quotes are not JSON's and are left alone.
- 500,000 characters at once, about 500 KB of English text.
Terms explained
- JSON
- A plain-text format for data, used by websites, apps and APIs.
- String
- A piece of text in JSON, written between double quotes.
- Escape
- A backslash and a letter or code that stands for a character, such as \n for a line break.
- Control character
- An invisible character such as a tab, a line break or a bell, which JSON wants escaped.
- Unescape
- To turn the escapes back into the characters they stand for.