JSON Escape

Paste any text and get it back as a JSON string, ready to drop into a file or a request body. Quotes, backslashes, tabs and line breaks are escaped for you.

How it works

The text is escaped by the browser's own JSON.stringify, the same code a JavaScript program uses to write JSON, so the result is exactly what a JSON reader expects.

A double quote becomes \", a backslash becomes \\, and a line break, tab or carriage return becomes \n, \t or \r. Other invisible control characters become \u escapes such as \u0000.

You choose whether the result has its surrounding double quotes, and whether letters outside plain ASCII, such as é or an emoji, are kept as they are or written as \u escapes. Nothing leaves the page.

How to use it

  1. 1 Choose whether to add the surrounding quotes. Leave them out to paste into quotes you already have.
  2. 2 Choose whether accents and emoji stay as written or become \u escapes.
  3. 3 Paste or type your text into the first box. The JSON string appears in the second box.
  4. 4 Press Copy result and paste it where it belongs.

Good to know

  • Escaping is the usual fix when a multi-line message, a SQL query or a Windows path breaks a JSON file you are editing by hand.
  • Choose \u escapes when the JSON will pass through a system that mangles non-ASCII text, such as an old terminal or a misconfigured email gateway.
  • An emoji written as \u escapes takes two of them, such as \ud83d\ude00. That is how JSON writes characters outside the first 65,536, and every reader joins them back.
  • To undo it, paste the string into JSON Unescape.

Browser support

  • Chrome 94 and later
  • Firefox 93 and later
  • Safari 16.4 and later
  • Edge 94 and later

These are the oldest versions with everything the tool uses. They are worked out from the tool itself, so they change when it does.

Version numbers checked on 2026-09-04.

Putting any text inside a JSON string safely

A JSON string starts and ends with a double quote, so a double quote inside it would end the string early. A backslash starts an escape, so a lone backslash inside it changes the meaning of the next character. And a raw line break is not allowed inside a string at all. These three rules are why pasting a paragraph, a stack trace or a Windows path into a JSON file so often breaks it. Escaping rewrites each problem character as a short sequence that starts with a backslash: \" for a quote, \\ for a backslash, \n for a line break and \t for a tab.

This tool uses the browser's JSON.stringify to do it. That matters because there are edge cases a hand-written find and replace usually misses. Carriage returns from Windows text become \r. Control characters that you cannot see, such as a NUL byte or an escape character copied from terminal output, become \u0000 or \u001b. Unpaired halves of an emoji, which can appear when text was cut in the wrong place, are written as \u escapes instead of producing invalid output. The result is exactly what a JavaScript program would write, so any JSON reader accepts it.

Two choices shape the output. The first is the surrounding quotes. With them, the result is a complete JSON value you can paste after a key and a colon. Without them, you get only the inside of the string, which is what you want when the quotes are already in your file and you are filling in the gap between them. The second is what happens to letters outside plain ASCII. JSON is Unicode, so é, ü, 日本 and emoji can stay as they are, and usually should, because the file stays readable. Writing them as \u escapes makes the file pure ASCII, which is safer when it passes through older systems that damage other characters.

With \u escapes on, an emoji becomes two escapes, such as \ud83d\ude00 for a grinning face. JSON escapes count UTF-16 code units, and characters beyond the first 65,536 need two of them, called a surrogate pair. Every JSON reader joins the pair back into one character, so nothing is lost.

Escaping is one half of a round trip. When you find a string full of \n and \" in a log line or an API response and want to read it as normal text, JSON Unescape does the reverse. Both tools run in your browser, so you can escape private messages, credentials in a config or customer data without sending them to a server.

Frequently asked questions

Which characters must be escaped in a JSON string?

Only three kinds: the double quote, the backslash, and control characters below U+0020, which include line breaks and tabs. Everything else, accents and emoji included, may appear as it is. This tool escapes exactly those, unless you ask for \u escapes for non-ASCII letters too.

Why is the forward slash not escaped?

JSON allows \/ but does not require it. JSON.stringify leaves / alone, and so does this tool. Some PHP code writes \/ to keep </script> out of HTML pages; both forms read back to the same text.

Should I include the surrounding quotes?

Include them when the result is a complete JSON value, for example a whole field value you will paste after a colon. Leave them out when you are pasting between quotes that are already in your file.

Is my text sent anywhere?

No. It is escaped in this page and never uploaded.

Related tools

Your files are processed on your device and are not uploaded. You can verify this in your browser’s developer tools under the Network tab.