JSON String Escape and Unescape – Escape JSON Strings Free Online

Use the free JSON String Escape and Unescape below: your data never leaves your browser — all work happens on your device, and nothing is uploaded to any server.

Escape and Unescape JSON Strings Correctly

JSON strings have rules. A double quote inside a string must be written as a backslash followed by a quote. A new line must be written as backslash and n. A tab becomes backslash and t, and a backslash itself becomes two backslashes. Get any of these wrong and the JSON is invalid, which usually shows up as a confusing parse error somewhere else in your program. This tool does the conversion for you in both directions, so you never have to escape by hand.

There are two directions, and both matter. Escaping takes ordinary text and produces the JSON form, with quotes around it, exactly as it belongs inside a JSON document. Unescaping takes the JSON form and returns the original text. Developers need both: escaping when building JSON by hand or in a test, unescaping when reading a JSON string out of a log file or an API response and wanting the real text back.

When Escaping Goes Wrong

The classic failure is pasting text with quotes into JSON without escaping them. The parser sees the inner quote, thinks the string has ended, and then chokes on the text that follows. The error message rarely points at the quote itself; it points somewhere later, which sends you hunting in the wrong place. Escaping first removes the whole class of error.

New lines cause a subtler failure. A real line break inside a JSON string is invalid. The text must contain the two characters backslash and n instead. The same applies to tabs and other control characters. When you paste multi-line text into a JSON field, every line break must become an escape sequence, and doing that by hand across a long message is exactly the kind of job where a mistake slips in. The tool converts all of them at once.

Backslashes are the third trap. A Windows file path like C:\Users\Maya contains backslashes, and each one must be doubled in JSON. A regular expression is full of backslashes too. If you paste either one into JSON without doubling, the parser reads the backslash pairs as escape sequences and produces different text than you intended, or fails outright. Escaping handles this mechanically and completely.

How to Use the Tool

Paste your text into the input box and press Escape. The output is the JSON string, including the surrounding double quotes, ready to paste into a JSON document. If you need the escaped content without the quotes, for example to embed it inside a larger string you are building, just remove the first and last characters of the output.

To go the other way, paste an escaped string and press Unescape. The tool accepts the string with or without its surrounding quotes. If the input is a complete JSON string, it parses directly. If it is the inner content of a string, the tool wraps it and parses that. Either way, the output is the original text, with real quotes, real line breaks, and real backslashes restored.

Check the output before you use it. Escaping is mechanical, but your input might contain something you did not expect, like a hidden control character from a copied log line. The output shows you exactly what the JSON parser will see, which is the whole point: there should be no surprises left by the time the text reaches your program.

Characters You Should Know

JSON defines a short list of escape sequences. Quote becomes backslash quote. Backslash becomes double backslash. Slash may become backslash slash, though it does not have to. Backspace, form feed, new line, carriage return, and tab have their own letter escapes. Any other character can be written as backslash u followed by four hex digits, which is how characters outside the basic set are sometimes represented.

Unicode needs no escaping in JSON. A character like é can appear directly in a JSON string, and most tools leave it alone. Some systems escape everything outside plain ASCII as unicode escapes, which is also valid JSON and means the same thing. Both forms parse to the same text, so do not worry if one tool shows é and another shows the escaped form. They are the same string.

Where This Comes Up in Real Work

Hand-written test data is the most common case. You write a JSON request body in an API client, and one of the fields contains a message with quotes or line breaks. Escaping it here gives you a body that parses on the first try. Log files are the second case: a logged JSON string shows escapes, and unescaping it gives you the message a user actually saw. Configuration files are the third: a message template stored as JSON needs its quotes escaped, and reading it back needs the reverse.

Embedding JSON inside JSON is the advanced case. Sometimes a JSON string itself contains JSON text, for example when one service forwards a payload as a string field. That inner JSON must be fully escaped, which means every quote and backslash inside it gets a backslash. Doing that by hand is miserable. Paste the inner JSON here, escape it once, and the result drops cleanly into the outer document.

Privacy

All work happens in your browser. Nothing you paste is uploaded or stored. The tool is free, needs no account, and handles text of ordinary size instantly.

Related tools

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top