
Different technologies need a common language to talk to each other. JSON is one of the most popular formats serving that purpose today, and whether you write code for a living or you're curious about how software works under the hood, understanding JSON will sharpen the way you think about data.
Picture a world where everyone speaks a different language and nobody can understand anyone else. JSON acts as a universal translator for computers, helping applications and systems exchange information in a format they all recognise. This article breaks JSON down into its core principles so that anyone, technical or not, can walk away with a solid grasp of how it works.
What Is JSON?
JSON (JavaScript Object Notation) is a standardised, lightweight format for exchanging data between different systems and platforms. It works like a digital lingua franca for automatic communication. Think of it like writing a recipe: there's a specific way to note ingredients and instructions so that anyone can recreate the dish.
To make this concrete, imagine you want to record details about a book in your library. You'd list:
- Title: The Lord of the Rings
- Author: John Ronald Reuel Tolkien
- Published: 1954
In JSON, that same information looks like this:
{
"title": "The Lord of the Rings",
"author": "John Ronald Reuel Tolkien",
"published": 1954
}Each piece of information sits in a key-value pair. The key ("title") describes what the data is, and the value ("The Lord of the Rings") holds the data itself. Curly braces {} wrap the whole thing together, and commas separate each pair.
A Brief History
JSON's origins trace back to the early days of the web. Around 2001, Douglas Crockford, a well-known figure in the JavaScript community, introduced JSON as a specification. He saw the need for a simpler data format that humans could read and write with ease, and that machines could generate and parse without overhead.
Before JSON, XML was the dominant format for data exchange. XML worked, but it was verbose: tags surrounded every piece of data, and the markup often outweighed the content itself. JSON offered a cleaner alternative with less syntax and a structure that mapped naturally to the data types programmers already used.
JSON became a global standard for data interchange and is now supported by nearly every programming language in active use.
How JSON Works
At its core, JSON is built on two structures:
- Objects are collections of labelled items. Picture a box of marbles where each marble has a label describing its colour and size. In JSON, objects use curly braces
{}and store data as key-value pairs. - Arrays are ordered lists. You might write down "milk", "eggs", and "bread" on a shopping list; JSON arrays work the same way, wrapping items in square brackets
[].
Here's a JSON object describing a person:
{
"name": "Delali",
"age": 28,
"isStudent": false,
"hobbies": ["reading", "coding", "traveling"]
}Notice how the "hobbies" key holds an array (a list of strings). JSON lets you nest arrays inside objects, objects inside arrays, and any combination of the two to represent complex data.
JSON Value Types
JSON supports six types of values. Here's what each looks like in practice:
Strings are text wrapped in double quotes. Use them for names, descriptions, and any human-readable content.
{
"greeting": "Hello, world",
"language": "English"
}The Rules of JSON
JSON has a strict syntax, and even a small mistake will cause parsers to reject the entire document. Here are the rules you need to follow:
- 1
Use double quotes for all keys and string values
Every key and every string value must be wrapped in double quotes. Single quotes are not valid JSON.
{ "name": "Delali" } - 2
Separate key-value pairs with commas
Each pair needs a comma after it, except the last one. A trailing comma after the final pair will break the parser.
{ "name": "Delali", "age": 28 } - 3
Wrap objects in curly braces, arrays in square brackets
Objects always use
{}and arrays always use[]. Mixing them up is one of the most frequent errors beginners make. - 4
No comments allowed
JSON does not support comments of any kind. If you need to annotate your data, add a dedicated key like
"_comment"or keep documentation separate from the JSON file. - 5
No trailing commas
Unlike JavaScript, JSON does not tolerate a comma after the last item in an object or array.
{ "colors": ["red", "green", "blue"] }
Common mistakes
These errors trip up beginners and experienced developers alike:
- Single quotes instead of double quotes. JSON requires double quotes.
{'name': 'Delali'}is not valid. - Trailing commas. A comma after the last item, like
{"a": 1, "b": 2,}, will cause a parse error. - Unquoted keys. Every key must be a string in double quotes.
{name: "Delali"}is not valid JSON. - Using undefined. JSON has
null, but it does not recogniseundefined. Usenullto represent missing values. - Comments in the file. JSON parsers will reject
//and/* */comments. Remove all comments before parsing.
A Complete Example
Here's a more involved example that brings objects, arrays, and nesting together. This represents a small library system:
{
"library": {
"name": "Accra City Library",
"location": {
"city": "Accra",
"country": "Ghana"
},
"books": [
{
"title": "The Lord of the Rings",
"author": "J.R.R. Tolkien",
"published": 1954,
"genres": ["fantasy", "adventure"],
"available": true
},
{
"title": "Things Fall Apart",
"author": "Chinua Achebe",
"published": 1958,
"genres": ["fiction", "historical"],
"available": false
},
{
"title": "Homegoing",
"author": "Yaa Gyasi",
"published": 2016,
"genres": ["fiction", "historical"],
"available": true
}
],
"totalBooks": 3
}
}This single JSON document captures nested objects (the library, its location, each book), arrays (the list of books, each book's genres), strings, numbers, and booleans all working together. A program receiving this data can parse it and immediately know the library's name, where it's located, what books it carries, and which ones are available.
Real-World Use Cases
JSON shows up everywhere in software. Here are some of the places you'll encounter it:
Web APIs
When your weather app fetches the current temperature, the server almost certainly sends back JSON. APIs (Application Programming Interfaces) use JSON as their default response format because it's lightweight and every programming language can parse it.
{
"city": "Accra",
"temperature": 31,
"unit": "Celsius",
"condition": "Sunny"
}Configuration Files
Tools like VS Code, ESLint, and Prettier store their settings in JSON files. When you customise your code editor's behaviour, you're editing JSON.
{
"editor.fontSize": 14,
"editor.tabSize": 2,
"editor.wordWrap": "on"
}Data Storage
Databases like MongoDB and Firebase store documents as JSON (or BSON, a binary variant). JSON's flexible structure lets you model data without rigid table schemas.
Internationalisation (i18n)
Applications that support multiple languages often store translations in JSON files, with one file per language:
{
"welcome": "Akwaaba",
"goodbye": "Nante yie",
"thankYou": "Medaase"
}If you want to experiment with JSON, open your browser's developer console (press F12) and type JSON.parse('{"name": "test"}'). The browser's built-in JSON parser will convert the string into a usable JavaScript object. You can also use JSON.stringify() to convert objects back into JSON strings.
Data Exchange Between Services
In any system where multiple services communicate (a payment processor talking to an order system, for example), JSON serves as the shared format both sides agree on. Its language-agnostic nature means a Python service can send JSON to a Go service without either side needing to know what the other is written in.
Why JSON Matters
JSON earned its place as the default data format for the web because it strikes the right balance between human readability and machine efficiency. It's simple enough for a non-technical person to read and understand, yet structured enough for software to parse and generate at scale.
Nearly every language, framework, and platform supports JSON natively. That universal adoption means choosing JSON for data interchange introduces zero friction; everyone already knows how to work with it.
Whether you're building APIs, configuring tools, storing data, or exploring how the systems around you communicate, JSON is the format you'll encounter most often. Understanding its structure and rules gives you a foundation that applies across every corner of software development.


