sequence."}}]}
{}JSON FYI

How to escape characters in JSON

The complete escape table, the difference between \u and \x, and why your backslashes vanish.

·5 min read

Inside a JSON string, the backslash starts an escape. The full set:

\"  double quote
\\  backslash
\/   forward slash (optional)
\b   backspace
\f   form feed
\n   line feed (newline)
\r   carriage return
\t   tab
\uXXXX  Unicode code point (4 hex digits)

Why do my backslashes disappear?

If you write a JSON string in source code (e.g. JavaScript), you have to escape the backslash for both the host language and JSON. To get a literal \n in your JSON, write "\\\\n" in the source string.

Unicode beyond U+FFFF

Code points above U+FFFF use a surrogate pair: \uD83D\uDE00 encodes 😀. Modern parsers handle this automatically.

Frequently asked questions

Is \x supported?+

No — JSON only supports \u for Unicode escapes. \x is a JavaScript thing.

Do I need to escape forward slashes?+

No, it's optional. It exists so JSON can be embedded inside <script> tags without breaking the closing </script> sequence.

Related tools & guides