JSON Guide β What Is JSON & How to Use It
A complete beginner-friendly guide to JSON (JavaScript Object Notation), the most popular data format on the web.
What Is JSON?
JSON (JavaScript Object Notation) is a lightweight data interchange format. It is easy for humans to read and write, and easy for machines to parse and generate. Despite its name, JSON is language-independent and used in virtually every programming language.
JSON was created by Douglas Crockford in the early 2000s and has become the de facto standard for data exchange on the web, largely replacing XML.
JSON Syntax
JSON has two primary structures:
- Objects β Unordered collections of key-value pairs, wrapped in curly braces {}
- Arrays β Ordered lists of values, wrapped in square brackets []
JSON Data Types
| Type | Example | Description |
|---|---|---|
| String | "hello" | Text in double quotes |
| Number | 42, 3.14 | Integer or floating point |
| Boolean | true, false | Logical values |
| null | null | Empty/missing value |
| Object | {...} | Key-value pairs |
| Array | [...] | Ordered list of values |
Common Use Cases
- REST APIs β Most web APIs send and receive data as JSON
- Configuration Files β package.json, tsconfig.json, etc.
- Data Storage β NoSQL databases like MongoDB store documents as JSON
- Web Applications β Frontend-backend communication
- Data Exchange β Sharing structured data between systems
Common Mistakes
- Using single quotes instead of double quotes for strings
- Adding trailing commas after the last item
- Including comments (JSON does not support comments)
- Using undefined as a value (use null instead)
- Forgetting to quote property names
JSON vs XML
JSON has largely replaced XML for web data exchange because it is more compact, easier to read, and faster to parse. XML is still used in legacy systems, SOAP APIs, and document-oriented data like SVG and HTML.
Work with JSON