Skip to content

JSON Escape

Escape quotes, backslashes, and line breaks so any text can sit inside a JSON string without breaking it.

How do you escape a string for JSON?

One stray quote kills an entire API request. JSON strings sit between double quotes, so certain characters inside them take a backslash: a double quote becomes \", a backslash becomes \\, a line break becomes \n, and a tab becomes \t, while control characters without a shorthand are written as \u sequences. Paste anything here and those rules get applied, returning text that sits inside a JSON string without causing a parse error.

That's the full list. Ordinary unicode: accents and emoji included: is legal in a JSON string exactly as typed, and a forward slash may be written as \/ but never has to be. The escaping covers the string's contents only: you still wrap the result in double quotes where it goes into the body, and escaping is not validation: the surrounding JSON still has to be well formed.

If the text lives in a Ferra table, message templates and product descriptions, notes riddled with line breaks, escape it on the way out to any API that takes a JSON body.

How the JSON escaper works

Paste the raw text, real line breaks, quotes, backslashes and all, and the escaped version appears immediately, ready to copy into your JSON between double quotes. Everything runs on the page; nothing is sent anywhere.

Text
Give it the exact text you want inside the JSON string, including its real line breaks. Don't pre-escape anything: the tool handles every character that needs it, and pre-escaped input comes out double-escaped.

Reading the output

Paste two lines. She said "hi" on the first, Path: C:\temp on the second, and the output is She said \"hi\"\nPath: C:\\temp. The quotes gain backslashes, the line break collapses into \n, and the backslash in the Windows path doubles to \\. Dropped between double quotes in a JSON body, it parses back to exactly the two lines you started with.

Run that output through a second time and \n becomes \\n, a literal backslash followed by an n, so the receiving system prints backslash-n instead of breaking the line. If that's what your rendered output shows, the text was escaped one time too many, not too few.

When to use the JSON escaper

Most people land here mid-request. The moment a curl body or a Postman payload needs a value with a quote or a line break in it: an address, maybe a bio or a chunk of template text: pasting it raw breaks the JSON, and this converts it to a form that parses.

The deeper case is JSON carrying JSON. Webhook payloads and config files often store a whole JSON object as a string field inside another object, and log pipelines do the same. Escaping the inner document is exactly this operation, and doing it by hand on anything longer than a line is how stray-quote bugs are born.

Tips for the JSON escaper

Escaping is mechanical; the bugs live in where you do it and how many times.

Escape values, not documents
Escape the text going inside one string, never the whole JSON body: the braces, colons, and commas of the body must stay unescaped.
Escape exactly once
Keep one raw copy of the text and escape it at the last step. A literal \\n in output means something escaped twice.
Add the quotes yourself
The output is the string's contents; it still needs the surrounding double quotes where it lands in the JSON.
Leave unicode alone
Accents and emoji are valid in JSON strings without escaping, no \u sequences needed for them.
Validate the final body
After inserting the escaped string, run the whole payload through a JSON validator. Escaping fixes strings, not structure.

Related templates

Browse all templates