JSON Formatter
Beautify, minify and validate JSON - and when it will not parse, be told exactly where.
Input
0 charactersOutput
Beautify, minify and validate JSON - and when it will not parse, be told exactly where.
JSON that came out of an API log or a config file is usually one long line, and JSON that will not parse usually fails somewhere you cannot see. This indents it so you can read it, minifies it when you need it small, and when it is broken it tells you the line and column and shows you that line.
Most of the time you are not here to make JSON pretty - you are here because something rejected it and did not say why. The parser reports the line, the column and what it expected, and the tool prints that line with the two around it. A missing comma four hundred lines into a config is a thirty-second fix once you know where it is.
JSON has never allowed either, but the files people actually hand you - tsconfig, VS Code settings, anything hand-edited - are full of them. Ticking the option strips them before parsing, and the tool then states how many comments and how many commas it removed. It is opt-in and reported precisely because a formatter that quietly alters your document is worse than one that refuses it.
It does not guess at what you meant. Beyond the two removals above, nothing is repaired: an unclosed brace, a single-quoted key or an unquoted key is reported, not rewritten. Sorting keys and re-indenting never reorder an array or change a string. The next section lists the few cases where the output can still differ from what you pasted.
Your JSON is parsed and written back out, so a few things come back normalised. Numbers are re-printed: 1.50 becomes 1.5, 1E3 becomes 1000.0 and -0 becomes 0, and a decimal with more digits than a 64-bit float can hold is rounded (0.1000000000000000055 becomes 0.1). Whole numbers are kept exactly up to 4,300 digits (longer ones are refused). If an object repeats a key, only the last value is kept, with no warning. NaN, Infinity and -Infinity are accepted and passed through even though standard JSON (RFC 8259) does not allow them, and a number too large for a float, such as 1e400, comes out as Infinity. If any of these matter to the system you are feeding, check for them yourself before trusting a clean result.
It is sent to the server to be parsed and sent straight back in the same response. Nothing is written to disk, cached or logged, and the usage record keeps only counts - size, nesting depth, which mode you picked - never the document.
Usually comments, trailing commas, single quotes or unquoted keys - all common in config files and none of them legal JSON. Tick "allow comments and trailing commas" for the first two; the others are genuinely invalid and have to be fixed.
Up to 2,000,000 characters per request; anything longer is refused with its exact length. For files that size a command-line tool such as jq is the better instrument.
Log pipelines and streaming loaders read one JSON object per line rather than one big array. Pick it and a top-level array comes back as one compact record per line.
No. Object key order is not meaningful in JSON, and array order - which is meaningful - is never touched. Sorting is there so two versions of the same document can be diffed without the noise.
In Excel for Microsoft 365, save it as a .json file and choose Data > Get Data > From File > From JSON. Power Query opens it: a top-level array shows as a List, To Table turns it into a column of Records, and the expand button (two arrows) in the column header splits each key into its own column; expanding a nested array adds one row per item. Power Query needs one valid JSON document, so fix any error here first, where you get the line and column, then save the Beautify or Minify output; JSON Lines output is meant for log tools. This tool does not itself convert JSON to CSV or Excel.
Python ships a checker: python -m json.tool data.json prints the document with 4-space indents, or stops with a message such as Expecting ',' delimiter: line 3 column 3. With jq installed, jq . data.json pretty-prints and jq empty data.json only checks, printing nothing when the file is valid. Neither accepts comments or trailing commas, so a config file that has them fails there; paste it here and tick "Allow comments and trailing commas" to see what was removed.
The parser expected an object key and found something else. Usually the keys use single quotes or none, as in {'name': 'Asha'} copied from Python or JavaScript, which stops at line 1, column 2: JSON needs double quotes around every key and string, and this tool never rewrites quotes, so change them yourself. The same message at a closing brace, as in {"a": 1,}, means a trailing comma; tick "Allow comments and trailing commas" to remove it. Expecting value at True, False or None means Python values: JSON writes true, false and null in lower case. In Python, json.dumps(data) gives valid JSON and print(data) does not. Errors are shown exactly as Python's parser words them, in English, so you can search the message as is.
The parser read one complete JSON value and then found more text after it. Common causes: a JSON Lines (NDJSON) log with one object per line, which stops at line 2, column 1; two documents pasted one after the other; or a // comment after the last closing brace, which "Allow comments and trailing commas" removes. This tool checks one document at a time, so paste a single record, or put the records inside [ ] with a comma between each pair; choosing JSON Lines then writes them back out one per line.