JSON string encoder / decoder

Escape text as a JSON string literal or decode a literal to text.

Text Stateless

Maximum input length per field: 65536 Unicode code points. See the operation limits in the instructions.

Quick guide

Try it with your own data when you’re ready.

Try an example

You enter

Text or quoted JSON string
Hello
world
Operation
Encode

You get

"Hello\nworld"
How it works & limits

Encoding adds the surrounding quotes and JSON escapes. Decoding accepts a JSON string, not an object or number.

Unicode surrogate pairs decode to their character; unpaired surrogates and control characters other than tab/newline/carriage return are rejected. Example: a line break becomes \n in the encoded string.