Step-by-step guide: How to Fix Invalid JSON: The 7 Most Common Errors
How to use the JSON Formatter and Validator
- Paste JSON into the box — an API response, a configuration file or a data export.
- Select Format to indent it for reading, or Minify to remove all unnecessary whitespace.
- If the JSON is invalid, the error message shows the line and column, with the problem line and a pointer underneath.
- Optionally sort object keys alphabetically to make two documents easier to compare with the Text Diff Checker.
- Copy or download the result.
Example: a trailing comma
This JSON looks fine at a glance:
{
"id": 42,
"tags": ["new", "sale"],
}
Validating it reports an error on line 4, column 1, and points out that the problem is a comma before the closing brace. JavaScript allows trailing commas, but the JSON standard does not. Remove the comma after ] and it validates.
Why JSON needs validating
JSON (JavaScript Object Notation) is the most common format for exchanging data between web services and storing configuration. Its rules are strict and simple, which is why one misplaced character makes a whole document unreadable to a program. Common mistakes include:
- trailing commas after the last item in an object or array;
- single quotes instead of double quotes around strings and keys;
- unquoted keys such as
{name: "Ada"}; - comments, which JSON does not allow;
- special values such as
undefined,NaNorInfinity.
How the formatter works
The tool uses your browser’s native JSON.parse, which follows the JSON standard (RFC 8259) exactly. If parsing succeeds, the data is written back out with JSON.stringify using the indentation you chose. When parsing fails, the tool converts the error position into a line and column number and looks at the text around it to suggest the likely cause.
Formatting never changes your data: values, types and the order of keys are preserved unless you choose to sort keys. A byte-order mark at the start of a file, which some editors add, is removed automatically.
A note on very large numbers
JavaScript represents numbers as 64-bit floating point, which stores integers exactly only up to 9,007,199,254,740,991. Larger integers — for example 64-bit IDs from some databases and APIs — are rounded when parsed, so their last digits can change after formatting. The tool warns you when your JSON contains such numbers. Many APIs send large IDs as strings for this reason.
Limitations to keep in mind
- Integers larger than 253 − 1 lose precision when parsed; the tool warns when it detects them.
- JSON5, JSON with comments and other relaxed variants are reported as invalid, because they are not standard JSON.
- Very large documents (tens of megabytes) may take a few seconds and use a lot of memory to format and display.
How your data is handled
JSON is parsed by your browser and never uploaded. It is safe to format API responses that contain personal or business data, provided you trust the device you are using.
Frequently asked questions
Is it safe to paste sensitive JSON here?
The data stays in your browser and is not sent to any server. As a general security habit, avoid pasting live credentials such as API keys or tokens into any website.
Can the tool fix invalid JSON automatically?
No. It tells you exactly where the problem is and suggests the likely cause, but it does not guess at corrections, because an automatic fix could silently change your data.
Does minifying change the data?
No. Minifying only removes whitespace between tokens. The parsed data is identical.
Why are my keys in a different order after sorting?
Sorting is optional and changes only the order of keys within objects, which has no meaning in JSON. Array order is never changed.