Encoding / Decoding

JSON String Escape

Escape or unescape strings for JSON (\n \" \uXXXX).

Original string
JSON Escape Result

What is JSON Escape?

JSON escape handles special characters in JSON strings, ensuring they can be safely included in JSON data. This tool escapes and unescapes JSON string content.

Escaped Characters

  • Backslash (\) → \\
  • Double quote (") → \"
  • Newline → \n
  • Tab → \t
  • Carriage return → \r

Use Cases

  • Embedding strings with special characters in JSON
  • API request/response handling
  • Configuration file editing

Frequently Asked Questions

How is JSON escaping different from URL encoding?
JSON escaping defines how characters are written inside a JSON string literal: quotes become \", newlines \n, control characters \uXXXX. URL encoding defines how characters travel inside a URL (%20 form). When a JSON payload goes into a query parameter, apply both: JSON-escape first, then URL-encode.
Why is Chinese sometimes escaped as \uXXXX and sometimes left as-is?
Both forms are valid JSON with identical meaning. Raw UTF-8 output is smaller and readable; \uXXXX survives transport chains with broken encoding assumptions. If an older API garbles Chinese, try enabling unicode escaping.
Which characters must be escaped in JSON?
The mandatory set: \" and \\, plus every control character U+0000–U+001F (\n, \r, \t have short forms; the rest must be \u00XX). Forward slashes never need escaping, though escaping them is legal.