JSON Formatting Guide
JSON is the universal language of data exchange on the web. This guide covers everything you need to know — from basic syntax to common mistakes and how to fix them.
Try it instantly
Use our free JSON Formatter and JSON Validator — no sign-up, runs entirely in your browser.
What is JSON?
JSON (JavaScript Object Notation) is a lightweight, text-based data format used to store and exchange structured data. Despite its name, JSON is language-independent and is supported by virtually every programming language.
It was created by Douglas Crockford in the early 2000s and has since become the dominant format for REST APIs, configuration files, and data storage.
JSON Syntax Rules
JSON has strict syntax rules. Violating any one of them will cause a parse error:
- ✓Keys must be strings wrapped in double quotes
- ✓String values must use double quotes, not single quotes
- ✓No trailing commas after the last item
- ✓No comments are allowed in standard JSON
- ✓Numbers cannot have leading zeros
- ✓true, false, and null are lowercase keywords
Valid JSON Example
{
"name": "DevUtils",
"version": 2,
"active": true,
"tags": ["developer", "tools", "free"],
"author": {
"name": "Dev Team",
"email": "hello@devutils.app"
},
"metadata": null
}Common JSON Errors
Trailing comma
✗ Wrong
{ "name": "Dev", "version": 1, }✓ Correct
{ "name": "Dev", "version": 1 }Single quotes
✗ Wrong
{ 'name': 'Dev' }✓ Correct
{ "name": "Dev" }Unquoted key
✗ Wrong
{ name: "Dev" }✓ Correct
{ "name": "Dev" }JSON Data Types
String
"hello world"Number
42 or 3.14Boolean
true or falseNull
nullArray
[1, 2, 3]Object
{ "key": "value" }How to Format JSON in Different Languages
JavaScript
JSON.stringify(data, null, 2);
Python
import json json.dumps(data, indent=2)
Go
json.MarshalIndent(data, "", " ")
JSON vs Other Formats
| Format | Readable | Comments | Best For |
|---|---|---|---|
| JSON | ✓ | ✗ | APIs, data exchange |
| YAML | ✓✓ | ✓ | Config files |
| XML | ~ | ✓ | Legacy systems |
| TOML | ✓✓ | ✓ | App config |