What Is JSON? A Beginner's Guide with Examples
JSON (JavaScript Object Notation) is the most common way data is exchanged on the web — between apps, APIs and config files. Despite the name, it's used far beyond JavaScript. Here's what it is and how it works.
Why JSON exists
Programs need a shared, text-based format to send structured data to each other. JSON is lightweight, human-readable, and supported by virtually every programming language — which is why it became the standard for APIs and configuration.
JSON syntax basics
JSON is built from two structures:
- Objects — key/value pairs in curly braces:
{ "name": "Sam", "age": 30 } - Arrays — ordered lists in square brackets:
[ "red", "green", "blue" ]
These can nest inside each other to represent complex data.
Data types
- String — in double quotes:
"hello" - Number —
42or3.14 - Boolean —
true/false - null — empty value
- Object and Array — for nesting
The strict rules
- Keys and strings must use double quotes (not single).
- No trailing commas after the last item.
- No comments allowed in standard JSON.
Break one and the whole file fails to parse — see our guide on fixing common JSON errors.
JSON vs XML
JSON is more compact and easier to read than XML, with less boilerplate. XML still appears in older systems and documents, but JSON dominates modern web APIs.
Work with JSON
Paste any JSON into our JSON formatter to pretty-print it, validate it, explore it as a collapsible tree, or minify it — all in your browser, so even sensitive data stays private.
FAQ
Is JSON only for JavaScript?
No — despite the name, nearly every language reads and writes JSON.
Can JSON store dates?
Not as a native type — dates are usually stored as ISO 8601 strings like "2026-06-25T10:00:00Z".