Developer

JSON Escape Encoder

Escape JSON strings for embedding in code or unescape them back.

All tools

Input

Output

Line one with \"quotes\"\nand a tab\there.

Frequently asked questions

When do I need to escape a JSON string?
Escape JSON when you need to embed it inside another string literal, like a JavaScript variable, a shell argument, or a JSON value itself. Each layer of nesting doubles the backslashes, which is why escaped JSON often looks dense.
Which characters must be escaped inside a JSON string?
The required escapes are the backslash, the double quote, and the control characters U+0000 through U+001F including newline, tab, and carriage return. Forward slash is optional, and other Unicode characters can stay literal.
Why does escaped JSON sometimes have extra backslashes?
Each layer of containment doubles the backslashes. A single escaped double quote inside one layer of JSON looks like \" but becomes \\" after a second round of escaping for embedding in another string. Count your backslashes by counting the layers.