← All guides

FIELD NOTES · 3 min read

Fix common JSON formatting errors

Find invalid quotes, trailing commas, comments, and large-number precision risks before formatting JSON.

Maintained by Wei2 Tools · Updated

JSON is not a JavaScript object literal

JSON requires double quotes around object keys and string values. Comments, single-quoted strings, undefined, NaN, and Infinity are not valid JSON. The input {"x":1,} is invalid because of the trailing comma; {"x":1} is valid. Check nested brackets and escape quotes inside strings.

Validate, then format or minify

Paste a non-sensitive sample into JSON formatter. Format JSON validates and adds indentation; Minify JSON validates and removes unnecessary whitespace. Invalid input produces an error rather than an automatic repair. Correct the source, run it again, and copy or download the valid result. Formatting does not validate an application-specific schema.

Keep exact identifiers as strings

This tool uses JavaScript JSON parsing. Integers above 9007199254740991 can lose precision, so an identifier such as "9007199254740993" should remain quoted when every digit matters. Formatting cannot recover precision already lost elsewhere. These limits also matter when comparing the result with another programming language.

References and further reading

Feedback