JSON is a lightweight data format used by APIs, configuration files and many web applications. When JSON is compressed onto one line or contains deeply nested objects, it can be difficult to inspect. Formatting adds indentation and line breaks so the structure is easier to read. Validation checks whether the text follows JSON syntax rules.
Formatting is different from validation
A formatter changes whitespace and indentation to make data readable. A validator checks whether the structure is syntactically valid. A document can be formatted neatly and still contain values that are wrong for the application. Syntax validation does not confirm that the data has the correct meaning or business rules.
Common JSON syntax mistakes
- Using single quotes instead of double quotes around strings.
- Leaving a comma after the final item in an object or array.
- Forgetting a comma between properties.
- Leaving a closing brace or bracket out of place.
- Using comments, undefined values or functions, which are not valid JSON values.
Review the structure step by step
- Start with a non-sensitive sample or a copy of the file.
- Paste the JSON into a trusted formatter or validator.
- Read the error message and inspect the nearby brackets, commas and quotation marks.
- Format the corrected text and compare the values with the original.
- Test the output in the application or API that will consume it.
Protect sensitive data
Configuration files can contain API keys, passwords, access tokens, customer details and internal endpoints. Do not paste those values into an online service unless the service is approved for that data. Replace secrets with dummy values before sharing a sample or asking someone to debug it.
Formatting does not replace testing
A valid JSON document may still fail an application because a required property is missing, a value has the wrong type or the receiving API expects a different structure. Use validation as one step in a broader review, and keep a backup before replacing a production configuration.