Guide
What Is JSON? A Developer's Guide
JSON is the format most APIs, config files, and log lines use to move structured data around. It is easy to read and easy for almost every language to parse, which is why it ended up everywhere. This guide covers what JSON is, the rules it follows, and the details that catch people out.
JSON in one sentence
JSON stands for JavaScript Object Notation. It is a text format for representing structured data as a combination of key-value pairs and ordered lists. It started in JavaScript but has nothing tying it to that language anymore. Python, Go, Rust, Java, and everything else can read and write it.
A JSON document is a single value. Most of the time that value is an object, written with curly braces, but it can also be an array, a string, a number, a boolean, or null on its own.
{
"name": "Ada",
"age": 36,
"active": true,
"roles": ["admin", "editor"],
"manager": null
}The data types
JSON has six value types and no more:
- String: text in double quotes, like "Ada".
- Number: an integer or decimal, like 36 or 3.14. There is no separate integer type.
- Boolean: true or false, lowercase.
- null: the empty value, lowercase.
- Array: an ordered list in square brackets, like [1, 2, 3].
- Object: a set of key-value pairs in curly braces.
Objects and arrays can hold any of these types, including other objects and arrays, which is how you build nested structure. There is no date type, no set, and no undefined. Dates are usually stored as strings, most often in ISO 8601 format like "2026-01-14T09:30:00Z".
The syntax rules that trip people up
JSON looks like a JavaScript object, but the rules are stricter. These are the ones that cause most parse errors:
- Keys must be double-quoted strings. { name: "Ada" } is a valid JavaScript object but invalid JSON. It has to be { "name": "Ada" }.
- Strings use double quotes, never single quotes.
- No trailing commas. A comma after the last item in an array or object is a syntax error.
- No comments. JSON has no comment syntax, even though many config formats that look like JSON allow them.
- No functions, no undefined, no dates as literals. Only the six value types above.
If you paste JSON into a formatter and it refuses to work, one of these five rules is almost always the reason.
JSON versus a JavaScript object
People treat these as the same thing, and they are close, but the differences matter. A JavaScript object is code that lives in memory and can hold functions, undefined values, and unquoted keys. JSON is text that follows a stricter grammar and can only hold data.
In JavaScript you convert between the two with JSON.stringify and JSON.parse. Stringify turns an object into JSON text and quietly drops anything JSON cannot represent, like functions and undefined. Parse turns JSON text back into an object.
const obj = { name: "Ada", greet: () => "hi" };
const text = JSON.stringify(obj);
// '{"name":"Ada"}' the function is gone
const back = JSON.parse(text);
// { name: "Ada" }Where you meet JSON
Most web APIs send and receive JSON. Configuration files like package.json and tsconfig.json are JSON. Structured logs are often one JSON object per line. NoSQL databases store JSON-shaped documents. When you work with any of these, being comfortable reading and fixing JSON pays off constantly.
When a payload is large or deeply nested, formatting it makes it readable, and a visualizer turns it into a shape you can follow. Both help far more than scrolling through a single minified line.
FAQ
Is JSON only for JavaScript?
No. JSON started in JavaScript but is language-independent. Every mainstream language has a way to parse and produce it.
Can JSON store dates?
Not as a native type. Dates are stored as strings, usually in ISO 8601 format, and parsed back into date objects by your code.
Why is my JSON invalid when it looks like a valid object?
It is probably a JavaScript object rather than JSON. Check for unquoted keys, single quotes, trailing commas, or comments, none of which JSON allows.