JSON String Escape

Turn plain text into a valid quoted JSON string. Escape quotes, backslashes and line breaks so a text value can be embedded in a JSON payload.

Encode a value

Paste the original text rather than a complete JSON object. Output includes the surrounding double quotes required for a string literal.

Represent a line break

An actual newline becomes the two-character escape sequence backslash-n inside the JSON source. Parsing that source restores the newline.

Avoid escaping twice

Running an already escaped literal through the encoder adds another layer. Use the original value unless nesting is intentional.

Keep output in its proper context

JSON escaping does not make text safe for every HTML or script context. Pass values through your framework when embedding them in a web page.

JSON String Escape FAQs

An object pasted here is treated as ordinary text. Use JSON Formatter to parse and format an object structure.
Copy the complete quoted result into JSON String Unescape to recover the original text value.