JSON Escape & Unescape — String Encoder

Make any text safe to paste into a JSON string — quotes, backslashes, newlines and Unicode — or turn an escaped string back into readable text or JSON.

Runs in your browserUpdated

Your data never leaves your computer. All processing happens 100% locally in your browser.

How to use the JSON Escape & Unescape

  1. Choose a mode: escape or unescape text, or convert between a JSON document and an escaped string.
  2. Paste the input; the output updates instantly.
  3. Use Reverse to run the opposite conversion on the result.

Which characters must be escaped in JSON?

CharacterEscape
Double quote "\"
Backslash \\\
Newline, carriage return, tab\n, \r, \t
Backspace, form feed\b, \f
Other control characters (U+0000–U+001F)\u0000–\u001f

Everything else, including emoji and accented letters, is allowed as-is in UTF-8 JSON. Tick ASCII only to write non-ASCII characters as \uXXXX for systems that cannot handle UTF-8. The forward slash may optionally be escaped as \/, which some servers do to keep </script> out of inline JSON.

JSON inside JSON

Some APIs and message queues carry a JSON document as a string field — for example an SQS message body or a webhook payload. JSON → string produces that double-encoded form; String → JSON removes one layer of escaping and pretty-prints the inner document, which is the quickest fix for the dreaded "{\"id\":1}" in logs.

In code

JSON.stringify(text)      // escape (JavaScript)
JSON.parse(escaped)       // unescape
json.dumps(text)          # Python
json.loads(escaped)

Need URL or HTML escaping instead? Use the URL encoder or HTML entity encoder.

Tools that pair well with the JSON Escape & Unescape

  • Base64 Encode / Decode — Convert text to Base64 and back with full UTF-8 support (accents, emoji), switch to URL-safe Base64, or drop a file to get its Base64 string or data URI.
  • JSON Diff — Find exactly what changed between two JSON documents — API responses, config versions, fixtures or exports — as a list of paths with old and new values.
  • JSON to YAML — Paste JSON and get clean YAML for Kubernetes manifests, Docker Compose, GitHub Actions or any config file.
  • YAML to JSON — Paste YAML — a Compose file, Kubernetes manifest or CI config — and get formatted JSON.

Frequently asked questions

How do I remove backslashes from a JSON string?
Choose Unescape text (or String → JSON if the string contains a JSON document). Escape sequences such as \" and \n are turned back into the real characters.
Do I need to escape single quotes?
No. JSON strings use double quotes, so single quotes are valid as-is.
Is my text uploaded?
No. Everything runs in your browser.

Related tools