JSON Formatter
JSON Formatter for developers — instant, offline-style and privacy-safe.
Escape a string for JSON or JavaScript — wrap it in quotes and escape the special characters — right in your browser. Paste raw text, get a ready-to-embed string literal.
Your browser is preparing the tool. It runs 100% locally.
Paste raw text and the tool returns it as an escaped string literal — wrapped in double quotes, with the characters that would otherwise break the string escaped: a quote becomes backslash-quote, a backslash is doubled, a newline becomes backslash-n, and so on. It produces a JSON string, which is also valid in JavaScript, ready to paste into code or a config. It runs in your browser; nothing is uploaded.
This tool takes any text and turns it into a safe, quoted string literal you can drop straight into JSON or JavaScript source. It wraps the text in double quotes and escapes the characters that would otherwise end the string early or be invalid, such as quotes, backslashes, newlines and tabs.
It is the quick way to embed an arbitrary value — a snippet of text, a path, a multi-line message — into code or a config file without hunting down every character that needs a backslash in front of it.
The tool serialises your text as a JSON string. That means it surrounds the whole value in double quotes and replaces each special character with its escape sequence: a double quote becomes a backslash followed by a quote, a literal backslash is doubled, and control characters like newline and tab become their backslash forms.
The result is a complete string literal, not just the inner text. Because JSON string syntax is a subset of JavaScript string syntax, the same output works in both — you can paste it wherever a double-quoted string is expected.
wrap the text in double quotes, and inside it:
• a double quote → backslash + quote
• a backslash → two backslashes
• a newline → backslash n · a tab → backslash t
• other control characters → backslash u escapesBefore: He said "hi" (followed by a new line, then) Line two
After: "He said \"hi\"\nLine two"The output includes the surrounding quotes — it is a complete string literal, not just the escaped contents. It escapes for JSON and JavaScript, not for HTML, URLs, regular expressions or shells.
Your text never leaves your device. It is escaped in your browser with no network request, so nothing is uploaded.
Because the work is local, you can safely escape text that contains tokens or private data without it being stored or sent anywhere.
Nothing persists between sessions — close the tab and the input and output are gone.
The output is a valid JSON string literal — the same result as a standard serialise step — so it is reliable for embedding text in JSON or JavaScript. The quotes are part of the output, because it produces a complete literal.
It escapes for one context: JSON and JavaScript strings. It is not the right tool for escaping into HTML, a URL, a regular expression, CSV or a shell command — each of those has different rules, and using a JSON escape there would be wrong.
Non-ASCII characters are kept as themselves rather than turned into backslash-u escapes, since they are valid in a JSON string as UTF-8. If you specifically need an ASCII-only literal, a different setting or tool would escape those too.
It produces a double-quoted literal. If your target needs single quotes, or a different quoting style, you would adjust the output by hand — the escaping inside would still be correct for double quotes.
Turn a multi-line or quote-containing value into a safe JSON string.
Paste an arbitrary value into JavaScript without manual escaping.
Double the backslashes in a path so it is a valid string literal.
Convert line breaks into backslash-n for a single-line literal.
For HTML, use an HTML encoder; for URLs, a URL encoder; each context has its own escaping. For a single-quoted target, take this output and adjust the quote style by hand — the inner escaping stays valid.
Escapes by producing a JSON string literal (the same as JSON.stringify), so the output is valid for JSON and JavaScript; honest that it does not escape for other contexts like HTML, URLs or shells.
JSON Formatter for developers — instant, offline-style and privacy-safe.
JSON Validator for developers — instant, offline-style and privacy-safe.
Base64 Encoder for developers — instant, offline-style and privacy-safe.
Fast, free Hash Generator that runs entirely client-side in your browser.
Fast, free UUID Generator that runs entirely client-side in your browser.
Fast, free CSS Minifier that runs entirely client-side in your browser.
It is free, private and runs entirely in your browser — no sign-up, no uploads, no limits.