JSON Formatter
Format, validate and minify JSON with exact error positions.
Your JSON is parsed and formatted entirely in your browser, so the document is never uploaded or stored on a server.
A JSON document that will not parse is usually one character away from working, and the hard part is finding that character. This formatter pretty-prints, minifies and validates JSON, and when the document is broken it points at the exact line and column where the structure gives way, with a message that names the mistake: a trailing comma, a single-quoted string, an unescaped newline, a property name without quotes.
More about JSON Formatter
Those positions come from a scanner written for this tool rather than from the browser. V8, JavaScriptCore and SpiderMonkey each word their syntax errors differently and only some of them include an offset, so a tool that forwards the engine message gives a different answer in every browser. One scanner means the same line, column and explanation everywhere, plus a Jump to error link that puts the cursor on the offending character.
Small documents are reformatted as you type. Anything past a quarter of a megabyte moves to a background worker so the page keeps responding, and a very large paste waits for you to press Format rather than starting work on its own. You can open a file from disk, switch between two spaces, four spaces and tabs, collapse the document to one line, and copy or download the result.
- Pretty-print with two spaces, four spaces or tab indentation
- Minify to a single line, then expand it again with one press
- Syntax errors reported with line, column and a Jump to error link
- Plain-language messages for trailing commas, single quotes and unquoted keys
- Warning when an integer is too large for JavaScript to hold exactly
- Documents over 256 KB formatted in a background worker, off the main thread
- Open a JSON file from disk, up to ten megabytes
- Copy the output or download it as a file
How to use it
- 1Paste your JSON into the left panel, or use Open file to load one from disk.
- 2Watch the right panel, which formats the document as you type.
- 3When it fails, read the line and column in the error message and use Jump to error to reach it.
- 4Pick two spaces, four spaces or a tab from the indent menu to change the output shape.
- 5Press Minify to collapse the document to one line, or Format to expand it again.
- 6Copy the result, or download it as a file.
Questions
Is my JSON uploaded anywhere?
No. Parsing, formatting and minifying all happen in your browser, and the document is never sent to a server.
Why did a large number change when I formatted it?
JavaScript holds numbers as doubles, so an integer above 9007199254740991 loses precision the moment it is parsed. The tool warns when it spots one, and the fix is to keep such IDs as strings.
Why does the error differ from the one in my console?
Every JavaScript engine words its JSON syntax errors differently and some omit the position altogether. This tool runs its own scanner, so the line, column and explanation are identical in every browser.
Does it accept comments, trailing commas or JSON5?
No, it checks strict JSON, so comments and trailing commas are reported as errors rather than quietly accepted. The message names them, which makes them quick to remove.
How large a document can it handle?
Input is capped at ten megabytes, pasted or opened from disk. Past a quarter of a megabyte the work moves to a background worker, and past one megabyte you press Format yourself instead of it running as you type.