Input

Mode:

Output

Formatted result will be displayed here

When do you need to escape a JSON string?

Whenever you paste text into a JSON string literal you have to escape any double quote, backslash, newline, tab, or control character, otherwise the parser rejects it. This tool takes raw input and returns a JSON-safe version with the correct backslash sequences, which you can then drop between quotes inside your payload. Handy when embedding HTML, regex patterns, or multi-line log excerpts.

Use Cases

Embed HTML inside JSON

Convert a chunk of HTML with double quotes into an escaped string you can assign to a JSON field without breaking the structure.

Paste stack traces into payloads

Newlines and tabs from a stack trace become \n and \t so the whole trace fits on one JSON line.

Build test fixtures

Quickly turn a paragraph of prose into a valid JSON string literal for a unit test or API contract example.

Prepare regex for config

Backslashes in a regex double up correctly so the JSON parser and the regex engine each see what they expect.

FAQ

What characters need escaping?

Double quote, backslash, and the control characters from U+0000 to U+001F. Forward slash is optional and usually left as is.

Does it add surrounding quotes?

It only escapes the content. Add the enclosing double quotes yourself when you paste the result into your JSON.

What about non-ASCII characters?

Unicode characters above the ASCII range are left as literal UTF-8 by default. Use the Unicode encoder if you specifically need \u escapes.

Can I reverse this?

Yes, use the JSON unescape tool to turn an escaped string back into its original text.