What is JSON?
JSON (JavaScript Object Notation) is a text-based data format for exchanging data between servers and applications. According to the official JSON specification, it is language-independent but uses conventions familiar to C-family programmers. Most REST APIs and many configuration files use it.
How to format JSON online
Paste your JSON into the JSON formatter and click "Format". The tool re-indents the JSON and adds line breaks so you can read and debug it.
Common JSON errors to fix
- Trailing commas. Remove the comma after the last item in an array or object. RFC 8259 does not allow it.
- Single quotes. Keys and string values need double quotes.
- Unescaped characters. Escape special characters, such as newlines, inside strings.
- Missing quotes. Every key and string value must be in quotes.
JSON best practices
- Use consistent indentation (2 or 4 spaces)
- Use camelCase for property names
- Avoid nesting deeper than 4 levels
- Include a root object for API responses
Minifying JSON
When you send JSON over a network or store it, you can minify it by removing all whitespace. The result is smaller and still valid JSON. The MDN JSON guide covers the format in more detail. The formatter's "Minify" button does this in one click.