JSON · Developer Guide
How to Format and Validate JSON
An API response can be valid JSON and still contain the wrong data. Separate syntax checks from data checks before copying a payload into a configuration file, test fixture, or request.
What is JSON?
JSON represents objects, arrays, strings, numbers, booleans, and null. It is a data format; a JavaScript object literal containing comments or unquoted property names is not necessarily JSON.
How the workflow works
- Keep a copy of the original response. Paste the complete body, excluding HTTP headers, into JSON Validator.
- Fix syntax errors first. Format the valid document to inspect nesting and field types.
- Check application rules separately: required fields, allowed values, and relationships between fields need a schema or application tests.
- Minify a reviewed document when compact text is useful. Minification does not encrypt or redact data.
Example: review an API response
The formatter uses two spaces for indentation. In this example, the array contains an object and the active field is a boolean, not a quoted string.
{"users":[{"id":"42","active":true}],"next":null}
{
"users": [
{
"id": "42",
"active": true
}
],
"next": null
}Common mistakes
- Trailing commas: remove the comma before a closing brace or bracket.
- Single quotes: use double quotes for property names and strings.
- Unescaped newlines: inside a string, use a backslash followed by n rather than a literal line break.
- Wrong structure: an array of objects is different from an object keyed by IDs; formatting cannot choose the correct structure for your API.
Practical use cases and limitations
For a failed request, first validate the outgoing body, then compare the expected field types with the API contract. For a fixture, format it before code review and run the application test after editing.
These tools parse through JavaScript values. Duplicate keys can collapse to the last value, and large numeric IDs can lose precision. Preserve identifiers as strings in the producing system and retain the source when exact bytes matter. Conversion to or from YAML also requires reviewing types; comments are not JSON data.
Privacy and security
The linked transformations run in your browser without uploading input to Small Tools servers. Use redacted samples when possible, especially before sharing screenshots, copied output, or fixtures. Formatting does not remove tokens or personal information.
Related tools
- JSON Formatter — Format and beautify JSON with readable indentation.
- JSON Validator — Check JSON syntax and see clear parsing errors.
- JSON Minifier — Remove unnecessary whitespace from JSON data.
- YAML to JSON — Convert YAML documents into formatted JSON.
- JSON to YAML — Convert JSON values into readable YAML.