By ToolzHive · Published
Formatting and validation solve different problems
Formatting adds indentation and line breaks so JSON is easier to read. Validation checks whether the input can be parsed as JSON. Neither proves that an API will accept the data: an API may require specific fields, types or allowed values. Use its documented schema for those requirements.
Start with a valid example
A small JSON object could be {"name":"Example","active":true,"items":[1,2,3]}. Object member names and string values use double quotes. true, false and null are lowercase literals. Numbers do not need quotes unless you intend to store them as strings.
Fix common syntax errors
Remove trailing commas, replace single-quoted strings with double-quoted strings and check matching braces and brackets. JSON does not allow JavaScript comments. Escape a double quote inside a string with a backslash. When a parser reports an error position, inspect the surrounding text as well as the preceding separator.
Use the formatter
Paste the input into JSON Formatter, select an indentation style and click Beautify. Use Minify to remove optional formatting whitespace for a compact result. Key sorting is optional and should not be used when a downstream workflow expects a particular serialized order. Copy the output only after checking the status and result.
Protect data meaning and sensitive values
Browser parsing and serialization can change number representations, and very large integer values may lose precision in JavaScript. Duplicate object keys can also conceal data because parsers may retain only one value. Do not treat successful parsing as a complete data-integrity check. Remove credentials, tokens and personal data from examples before sharing them.
Put this guide into practice
- JSON Formatter & Validator — Beautify, minify and validate JSON with helpful error messages.