JSON Formatter
Pretty-print messy or minified JSON with 2-space indents.
Paste raw text and get a JSON or JavaScript string literal: the text wrapped in quotes, with the special characters escaped, ready to embed.
Your browser is preparing the tool. It runs 100% locally.
Paste raw text and the tool returns it as an escaped string literal: The text is wrapped in double quotes, and the characters that would otherwise break the string are 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. Your browser does the escaping and uploads nothing.
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.
Use it 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, and 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, so it is a complete string literal rather than the escaped contents alone. 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 carries over between visits. 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 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 stays 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. It does not escape for other contexts such as HTML, URLs or shells.
Pretty-print messy or minified JSON with 2-space indents.
Paste JSON and find out whether it parses.
Standard Base64 for any text, emoji included.
MD5, SHA-1 and the SHA-2 hashes of any text, as you type.
Up to 500 random version 4 UUIDs at once.
Strips comments and whitespace to put a stylesheet on one line.
Paste, run and copy. The code stays in your browser and you don't need an account.