CoreJSON

JSON Escape / Unescape

This escape / unescape tool turns any text — including newlines, tabs, double quotes, backslashes and emoji — into a valid JSON string literal you can paste straight into JSON, and converts escaped sequences such as "\n", "\"" and "\uXXXX" back into their original text. It is handy for embedding multi-line SQL, regular expressions, certificate fragments or API payloads into JSON config, or for recovering a JSON string field from a log. Conversion runs locally in your browser, so nothing is uploaded.

Open in the workbench Runs locally · nothing is uploaded

How to use it

  1. 1

    Paste the raw text

    Paste the text you want to embed in JSON (multi-line, with quotes or backslashes is fine) into the workspace input.

  2. 2

    Click Escape

    The output becomes a JSON string literal with surrounding double quotes: newlines become \n, tabs \t, quotes \" and backslashes \\. Paste it into any JSON value position.

  3. 3

    Unescape to restore

    When you have a string fragment from JSON, paste it and click Unescape to recover the original text. Input works with or without the surrounding double quotes.

  4. 4

    Copy the result

    Copy the escaped or restored text. If you need to check whether an entire JSON document is valid, use the validator pane.

Key features

Covers every special character

Newlines, carriage returns, tabs, double quotes, backslashes and control characters are escaped to the JSON standard, with control characters emitted as \uXXXX so pasting never breaks the structure.

Unescape accepts both inputs

A full literal with surrounding double quotes is parsed with JSON.parse; if you paste only the inner content it is wrapped automatically before restoring.

Non-ASCII stays legible

Non-ASCII characters (CJK, emoji and more) are kept as-is instead of being forced to \uXXXX, so you can still proofread the escaped output.

Clear error feedback

Unescaping an invalid sequence (such as a lone backslash or a truncated \u escape) returns a readable error instead of an opaque exception.

On the same page as validate / format

The escaped result can be formatted, minified or validated on the same page, and the tree view confirms the nested structure — no copy-paste between sites.

Open and go

No sign-in and no ads: paste and convert.

Common errors & troubleshooting

  • ! The escaped output is a string literal (with one pair of double quotes), so put it in a JSON value position rather than treating it as the whole document. Parsed on its own it is still valid and yields the original string.
  • ! Regular expressions are backslash-heavy: seeing \\d+ after escaping is normal — unescaped it is d+. Two levels of backslashes are expected when JSON nests escapes.
  • ! Strings copied from logs often come with surrounding double quotes, which Unescape handles directly. If you copy the surrounding braces too, format the JSON first and then take the field.
  • ! A newline inside a JSON string must be written as \n; a literal line break inside quotes is a syntax error and is one of the most common mistakes in hand-written configs.

Frequently asked questions

What exactly does JSON escaping convert?

Some characters cannot appear literally inside a JSON string: a double quote would end the string early, a backslash starts an escape, and control characters such as newlines are not allowed between quotes. Escaping rewrites them as \", \\, \n, \t, \uXXXX and so on, and adds the surrounding double quotes so any text can be embedded safely.

Why did my newline become \n? Can I keep real line breaks?

The JSON specification does not allow a literal newline inside a string; it must be the two characters \ and n. A parser turns that back into a real newline on read, so no information is lost — only the stored form differs. For multi-line readability, use a JSON object with indentation rather than embedding newlines in a string.

What should I do if unescaping reports an error?

The usual causes are a lone backslash (for example a Windows path like C:\new, where \n is read as a newline escape) or a truncated \uXXXX sequence. First confirm the content was copied from a complete JSON string; if it is a whole document, run it through the format / validate tools before extracting the field.

Are non-ASCII characters escaped to \uXXXX?

No. The tool serialises to the modern JSON standard, keeping non-ASCII characters as-is (JSON only requires escaping quotes, backslashes and control characters). If a legacy system demands pure-ASCII output, handle that conversion on the receiving side.

Related tools