Learn/Getting Started

JSON for Beginners — Make Your First API Call in 5 Minutes

Never worked with JSON before? This guide starts from absolute zero — what JSON looks like, how to read it, and by the end, you'll make a real API call and see live data. No prior experience needed.

Beginner~10 min read

What Does JSON Look Like?

JSON is just text that organizes data in a structured way. Think of it like a label on a package:

Your first JSON objectjson
1{
2 "name": "Alice",
3 "age": 28,
4 "developer": true,
5 "city": "San Francisco"
6}

That's it. Curly braces {} hold key-value pairs. Every key is in double quotes. Values can be text, numbers, true/false, or null.

Think of JSON as...

A shipping label with fields. The "key" is the field name, the "value" is what goes in that field. Every API in the world uses this format to send data.

The 6 Types of JSON Values

JSON Value Types
All 6 types in one JSONjson
1{
2 "name": "Alice",
3 "age": 28,
4 "active": true,
5 "nickname": null,
6 "address": {
7 "city": "SF",
8 "zip": "94102"
9 },
10 "skills": ["JavaScript", "Python", "SQL"]
11}
TypeExampleUsed For
String"hello"Text, names, IDs, dates
Number42, 3.14Counts, prices, measurements
Booleantrue / falseFlags, toggles, yes/no
Nullnull"No value" or "unknown"
Object{"key": "value"}Grouped data (like a record)
Array["a", "b", "c"]Lists of items

Step 1: Make an API Call with curl

Open your terminal and run this command. It fetches real data from a free public API:

curl — fetch JSON from an APItext
1curl https://jsonplaceholder.typicode.com/users/1

You'll see something like this:

API response (JSON)json
1{
2 "id": 1,
3 "name": "Leanne Graham",
4 "username": "Bret",
5 "email": "[email protected]",
6 "phone": "1-770-736-8031 x56442",
7 "website": "hildegard.org",
8 "company": {
9 "name": "Romaguera-Crona",
10 "catchPhrase": "Multi-layered client-server neural-net"
11 }
12}

What Just Happened?

You asked an API server for user #1. It responded with a JSON object containing that user's data. Every modern app does this thousands of times a day.

Step 2: Make an API Call with JavaScript

Fetch JSON in the browser or Node.jsjavascript
1// Paste this in your browser console (F12 → Console)
2const response = await fetch('https://jsonplaceholder.typicode.com/users/1');
3const user = await response.json();
4
5console.log(user.name); // "Leanne Graham"
6console.log(user.email); // "[email protected]"
7console.log(user.company.name); // "Romaguera-Crona"

Three lines of code. That's all it takes to fetch JSON data and use it in your app.

Step 3: Make an API Call with Python

Fetch JSON with Python requestspython
1import requests
2
3response = requests.get('https://jsonplaceholder.typicode.com/users/1')
4user = response.json()
5
6print(user['name']) # Leanne Graham
7print(user['email']) # [email protected]
8print(user['company']['name']) # Romaguera-Crona

Reading Nested JSON

Real API data is usually nested — objects inside objects. Access them by chaining keys:

Accessing nested datajavascript
1const data = {
2 "user": {
3 "profile": {
4 "name": "Alice",
5 "social": {
6 "twitter": "@alice_dev"
7 }
8 }
9 }
10};
11
12// Chain the keys to reach nested values
13data.user.profile.name; // "Alice"
14data.user.profile.social.twitter; // "@alice_dev"

Creating Your Own JSON

You don't just read JSON — you create it when building apps:

Creating JSON in JavaScriptjavascript
1const myData = {
2 name: "Your Name",
3 skills: ["HTML", "CSS", "JavaScript"],
4 experience: { years: 1, level: "beginner" }
5};
6
7// Convert to JSON string (for sending to an API)
8const jsonString = JSON.stringify(myData, null, 2);
9console.log(jsonString);

3 Golden Rules

1

Always use double quotes

Keys and string values must use " not '. This is the #1 beginner mistake.

2

No trailing commas

The last item in an object or array must NOT have a comma after it.

3

No comments

JSON does not support // or /* */ comments. Store notes elsewhere.

Try It Yourself

Write your own JSON object describing yourself. Include a name (string), age (number), a boolean, and an array of hobbies.

Try It Yourself

Edit this JSON and hit validate — if it passes, you wrote valid JSON!

What to Learn Next

Frequently Asked Questions

What does JSON stand for?
JavaScript Object Notation. Despite the name, JSON is language-independent and used in every programming language — Python, Java, Go, Rust, PHP, Ruby, C#, and more.
Do I need to know JavaScript to use JSON?
No. JSON is a text format that any language can read and write. You can use JSON in Python, Java, or any other language without knowing JavaScript.
What is an API?
An API (Application Programming Interface) is a way for two programs to talk to each other. When you fetch weather data from a weather service, you are using their API. Most modern APIs send and receive data as JSON.
Is JSON hard to learn?
No. JSON has only 6 data types and a few simple rules. Most developers learn the basics in 10-15 minutes. The syntax is similar to how you would naturally organize data.
Where is JSON used?
Everywhere: REST APIs, config files (package.json, tsconfig.json), databases (MongoDB, PostgreSQL JSONB), browser localStorage, mobile apps, IoT devices, and inter-service communication.