curly{bits}

curlybits / JSON Escape

JSON Escape & Unescape

Turn any text into a valid JSON string: quotes, backslashes, line breaks and tabs are escaped for you. Or paste an escaped string like {\"id\":1} to get the original text back. Handy for config values, API payloads and log messages.

Input
Output

How to use the JSON Escape & Unescape

  1. Choose Encode to escape text, or Decode to unescape it.
  2. Paste your text on the left. The result appears on the right as you type.
  3. When escaping, tick Add surrounding quotes for a complete JSON string, or Escape non-ASCII for plain-ASCII output.
  4. Click Copy, or the ⇄ button to send the result back as input.

What gets escaped

CharacterEscaped as
Double quote "\"
Backslash \\\
Line break\n (and \r for Windows line endings)
Tab\t
Other control characters\u0000 to \u001f
Non-ASCII, like é or 😀 (optional)\u00e9, \ud83d\ude00

Single quotes and forward slashes don't need escaping in JSON. Escaping / as \/ is allowed, and is sometimes used to keep </script> out of HTML pages.

JSON vs JavaScript strings

A JSON string is also a valid JavaScript string in double quotes, so the output works in JS and TypeScript code too. Unescaping accepts only JSON escapes. JavaScript-only forms like \x41 or single-quoted strings will show an error.

Double-escaped JSON

JSON stored inside another JSON value, common in logs, queues and databases, looks like "{\"id\":1}". Decode it once to get {"id":1}, then format it with the JSON formatter. If it was escaped twice, decode twice.

Frequently asked questions

Do I need to escape single quotes?

No. JSON strings use double quotes, so single quotes are fine as they are.

Why does unescaping fail?

The text has something that isn't allowed in a JSON string: an unescaped double quote, a raw line break, or an escape like \x that JSON doesn't support. The error says what and where.

Is my text uploaded?

No. Everything happens in your browser.

Add this JSON escape and unescape tool to your website

Free for blogs, schools and businesses. Copy the code below and paste it into your page's HTML. The tool works exactly like this one and runs in your visitors' browsers, so nothing is uploaded. Please keep the credit line so others can find it too.

Preview embed ↗