How to Format and Validate JSON (and Fix the Most Common Errors)
JSON is the everyday language of web APIs and app settings, but a response squeezed onto one line is almost unreadable, and a single stray character can make a whole file invalid. A formatter and validator turns that into a readable, checked document in a second.
What formatting and minifying do
- Format (beautify) adds indentation and line breaks so you can see the structure.
- Minify removes all unnecessary whitespace to make the data smaller for transfer or storage.
- Validate checks that the text really is valid JSON and reports where it breaks.
Sorting keys changes only how the text looks. JSON objects are unordered, and array order is never changed.
The five most common JSON errors
| Error | Fix |
|---|---|
| Trailing comma after the last item | Delete the comma |
| Single quotes around text | Use double quotes for keys and strings |
| Unquoted keys such as {name: "Ann"} | Write {"name": "Ann"} |
| Comments (// or /* */) | JSON does not allow comments; remove them |
| Missing comma between items | Add the comma |
The error message gives the line and column where parsing stopped. The real mistake is often a little before that point, so look at the previous line too.
Valid JSON values
| Type | Example |
|---|---|
| String | "hello" |
| Number | 42 or 3.14 |
| Boolean | true or false |
| Null | null |
| Array | [1, 2, 3] |
| Object | {"key": "value"} |
Step by step in the formatter
- Paste your JSON into JSON Formatter & Validator.
- Choose Format, Minify or Validate.
- If there is an error, read the line and column and fix it.
- Copy the cleaned result.
Converting JSON to CSV
Spreadsheets need rows and columns, so a list of JSON objects can be flattened into a CSV. With flattening on, nested objects become dotted column names such as address.city. Arrays are written as JSON text in one cell, because CSV has no native list type. If your CSV uses semicolons, as in many European spreadsheet settings, choose the semicolon delimiter. You can also go the other way, from CSV to JSON, or use the Excel & CSV Converter for .xlsx files.
Safety and privacy
- API responses can contain tokens and personal data; never paste secrets into tools you do not trust.
- Parsing, formatting and conversion here run locally in your browser, and nothing is sent to a server.
- Remove sensitive values before sharing JSON in a forum or bug report.
Key terms: JSON formatter, JSON validator, JSON minify, JSON beautifier, JSON to CSV, CSV to JSON, parse error, trailing comma, nested objects, API response.
Frequently asked questions
Is my JSON uploaded anywhere?
No. Parsing, formatting and conversion all run in your browser.
Why does my JSON say it is invalid?
The usual causes are trailing commas, single quotes, unquoted keys, comments and missing commas. The message shows the line and column.
How are nested objects handled when converting JSON to CSV?
With flattening on, nested objects become dotted column names like address.city. Arrays are written as JSON text in one cell.
Can I convert a CSV that uses semicolons?
Yes. Choose the semicolon delimiter before converting.
Does sorting keys change the meaning of the data?
No. JSON objects are unordered, so sorting keys only changes the appearance. Array order is never changed.
Got JSON that will not parse?
Try JSON Formatter & Validator →Put this guide into practice
JSON Formatter & Validator — Format, validate and minify JSON, or convert JSON to CSV.
XML & JSON Converter — Convert XML to JSON and JSON to XML, free and private.