JSON Escaper
Escape JSON strings or unescape formatting strings securely in your browser.
Escape & Unescape JSON Strings Online: Handle Quotes, Backslashes & Newline Characters
You are writing an API integration script, passing a JSON string inside a terminal cURL command, or storing HTML markup inside a PostgreSQL or MongoDB JSON column.
When you run your request, the server crashes with a fatal JSON parse error: "Unexpected token at position 18 (line 1, column 19)".
Why did this happen? Because in standard JSON syntax, string values are delimited by double quotes. If your text contains internal double quotes, raw line breaks (\n), or backslashes (\), the parser misinterprets the characters as syntax boundaries rather than literal text.
Our free online JSON Escaper solves this instantly. Safely escape raw text, code snippets, and multiline HTML blocks into valid JSON strings—or unescape escaped strings back into readable text. Everything runs locally in your browser with zero latency.
Official RFC 8259 JSON Escape Sequences
| Raw Character | Escaped Code | Purpose & Technical Reason |
|---|---|---|
| " (Double Quote) | \" | Prevents premature termination of string boundaries |
| \ (Backslash) | \\ | Escapes the escape character itself |
| [Line Break / Newline] | \n | Replaces literal unescaped carriage returns |
| [Carriage Return] | \r | Normalizes Windows CRLF newline endings |
| [Tab Character] | \t | Preserves horizontal indentation formatting |
| Unicode Symbol | \uXXXX | Encodes special international characters safely in 7-bit ASCII |
Escape Mode vs. Unescape Mode
1. Escape Mode (Raw → JSON Safe)
Takes multi-line paragraphs, HTML templates, or strings containing quotes and converts them into a single-line escaped string ready to be placed inside a JSON property value.
Output: Hello \"World\"
2. Unescape Mode (JSON Safe → Human Text)
Takes an escaped API payload or database dump containing \n, \", \\ and converts it back into natural, multi-line, formatted text for easy human reading.
Output: Line 1 (on first line)
Line 2 (on second line)
Frequently Asked Questions
What is "double-escaping" and how do I fix it?
Double-escaping occurs when a string that was already escaped gets escaped a second time (e.g., transforming \" into \\\"). This often happens in bash terminal scripts or nested API payloads. You can run double-escaped strings through our "Unescape" tool once or twice to restore clean original formatting.
Does this tool support HTML tags inside JSON?
Yes! It safely escapes complex HTML templates containing attributes, quotes, and line breaks so they can be stored in CMS databases without causing syntax corruption.
Is my code or data kept private?
Completely private. All string escaping and regular expression parsing execute client-side inside your local browser memory via JavaScript. None of your proprietary code or payload strings are sent to our servers.