JSON Escape and Unescape

Turn any text into the inside of a JSON string, or turn an escaped string such as {\"a\":1} back into plain text.

How to use

  1. Choose Escape, Escape (ASCII only) or Unescape.
  2. Paste your text into [Input]. The result appears in Output as you type; a broken escape is reported with its line and column.
  3. Press Copy to copy the result, or Clear to start over.

Examples

InputOutput
He said "OK" Path: C:\logsHe said \"OK\"\nPath: C:\\logs
{\"name\":\"Kobako\",\"tags\":[\"json\"]}{"name":"Kobako","tags":["json"]}
cafΓ© ζ—₯本 πŸ˜€caf\u00e9 \u65e5\u672c \ud83d\ude00

About this tool

What must be escaped

Inside a JSON string, RFC 8259 requires three kinds of characters to be escaped. Everything else may appear as is.

Character Escaped as
Double quote " \"
Backslash \ \\
Line feed, carriage return, tab \n, \r, \t
Backspace, form feed \b, \f
Other control characters (U+0000–U+001F) \u + four hex digits, e.g. \u0001

Escape writes exactly these and leaves letters such as Γ©, ζ—₯本 or emoji untouched, because a UTF-8 JSON file can hold them directly. So Say "hi" on one line and C:\temp on the next becomes Say \"hi\"\nC:\\temp.

Why "/" may be escaped

JSON also allows \/. It is optional: a slash never has to be escaped. It exists so JSON embedded in an HTML page can't accidentally contain the closing script tag. This tool leaves / alone when escaping and turns \/ back into / when unescaping.

\uXXXX and surrogate pairs

Any character can be written as a backslash, a u and its four-digit hex code; the hex letters may be upper or lower case. Escape (ASCII only) does this for every non-ASCII character, for systems that mangle UTF-8. For example, Γ© is U+00E9, so it is written as backslash, u, then 00e9. Characters above U+FFFF don't fit in four digits, so they become a UTF-16 surrogate pair: πŸ˜€ (U+1F600) turns into two such codes, D83D and DE00. The examples table above shows the exact output.

Double-escaped JSON

When a program turns an object into JSON and then stores that text inside another JSON string, every quote gains a backslash: {"a":1} becomes {\"a\":1}. You see this in log lines, message queues and API fields that carry a "payload" as a string. Unescape removes one layer, with or without the outer quotes. If the result still has \", it was escaped twice; unescape it again.

Not URL encoding, not HTML entities

JSON escaping only makes text safe inside a JSON string. URLs use percent-encoding (a space becomes %20) and HTML uses entities (&). Mixing them up leaves stray % or & sequences in your data.

Privacy

Everything runs in your browser. Nothing you paste is uploaded, so logs with tokens or customer data stay on your device.

Frequently asked questions

Do I need to escape the forward slash in JSON?

No. JSON allows \/ but never requires it. Only the double quote, the backslash and control characters such as line breaks and tabs must be escaped.

Why does an emoji become two \u codes?

\u takes four hex digits, which only reach U+FFFF. Characters above that, such as πŸ˜€ (U+1F600), are written as a UTF-16 surrogate pair: two \u codes, D83D and DE00.

Should I include the surrounding double quotes when unescaping?

Either way works. The unescaper accepts a string with or without the outer double quotes and returns the plain text.

What does a bad escape error mean?

A backslash is followed by a character JSON doesn't allow, such as \x, or \u has fewer than four hex digits. The error shows the line and column. Windows paths like C:\Users are a common cause.

Is my text uploaded anywhere?

No. Escaping and unescaping run in your browser, and nothing you paste leaves your device.