Skip to content
ع
Tutorials

JSON for Beginners: What It Is and How to Read and Write It Without Errors

JSON is the shared data language of websites and apps. Its rules are few and strict, and understanding them lets you read what systems send and fix errors yourself.

Ahmad Khreiswebmaster5.0(2)
Published 14 min read
Illustration for the article: What Is JSON? A Simple Beginner's Guide with Practical Examples

JSON stands for JavaScript Object Notation: a simple text format for exchanging data between websites, apps and systems. When your site sends a request to a payment service, a weather app shows the temperature, or you add structured data so Google understands your page, the data usually travels as JSON. Its rules are few but strict, and understanding them lets you read what systems send and fix errors yourself.

Key takeaways

  1. 1JSON is key/value pairs inside curly braces.
  2. 2Six value types: string, number, boolean, null, object and array.
  3. 3Keys and strings use double quotes; no comments and no comma after the last item.
  4. 4Validate any file with a tool before using it.

What does a JSON file look like?

A JSON file is a tree: a main object holds keys, and each key has a value that can be simple like a string or number, another object, or an array of values. Here's an example of customer data:

The structure of a customer JSON file

Main object { }
  1. "name": string
    • "Sara Ahmad"
  2. "orders": number
    • 3
  3. "active": boolean
    • true
  4. "address": nested object
    • "city": "Riyadh"
    • "zip": "12345"
  5. "tags": array
    • "vip"
    • "newsletter"
Illustrative example. An object groups keys inside curly braces { }, and an array groups values inside square brackets [ ].

In the file, this example is written as: {"name": "Sara Ahmad", "orders": 3, "active": true, "address": {"city": "Riyadh", "zip": "12345"}, "tags": ["vip", "newsletter"]}.

Minified and pretty-printed: the same content in two shapes

You may open one file and find a single long line with no spaces, then open another with the same data neatly arranged on separate lines with clear indentation. Both are valid and carry exactly the same information; spaces and line breaks outside quotes change nothing in the meaning. The minified version is used when sending data between systems because it's smaller and travels faster; the pretty-printed version is for when a person needs to read or edit it.

So when you receive a minified file from a system, don't try to read it as is. Run it through a formatter first to re-indent it, so the nesting of objects and arrays becomes clear and following the levels of data is much easier. After editing, you can minify it again if the system needs that.

The six value types

Every JSON value is one of just six types, and knowing them is enough to read any file:

TypeExampleNote
String"Riyadh"Always in double quotes
Number3 or 19.99No quotes and no thousands separators
Booleantrue or falseLower case, no quotes
NullnullMeans "no value"
Object{"city": "Riyadh"}Keys and values inside curly braces
Array["vip", "new"]A list of values inside square brackets

Example: one product with all its details

Imagine a product in a store: it has a name (a string), a price (a number), availability (a boolean, true or false), a list of available colours (an array of strings), dimensions (a nested object with length, width and weight) and a discount date not yet set (null). One file contains all six types together, each value in its logical place: the name in quotes, the price without them, the colours in square brackets and the dimensions in curly braces.

That nesting is the format's real strength: one order can contain the customer, the customer contains their address, and the order contains a list of products, each with a quantity and price. When you read a large file for the first time, start at the top level and ask: what is this object? Then go down level by level, just like browsing folders inside folders.

The most common errors that break a file

Most JSON errors are small, but any one of them makes the whole file invalid:

Invalid

  • Unquoted keys: {name: "Sara"}
  • Single quotes: {'name': 'Sara'}
  • A comma after the last item: ["a", "b",]
  • A comment inside the file: // note

Valid

  • {"name": "Sara"}
  • Double quotes only
  • ["a", "b"]
  • No comments; keep notes elsewhere

And watch for strings containing a double quote; it needs a backslash before it, like this: \".

How do you read an error message and find the cause?

Error messages look scary, but they usually tell you exactly where to look. A message like "Unexpected token } at line 14, column 3" means the parser reached line 14 and found a closing brace it didn't expect. The cause is usually not on line 14 itself but just before it: a trailing comma after the last item on line 13, or a quote that wasn't closed a few lines earlier.

The practical rule: go to the line mentioned, then step back a line or two and look for the three most common mistakes: an extra or missing comma, a single quote instead of a double one, and a bracket opened but never closed. If the file is long, paste it into a validator that highlights matching brackets and re-indents the text, so the problem shows up visually in seconds instead of counting brackets by hand.

Watch out for text copied from word processors or chat apps: some turn straight quotes into decorative curly quotes, which the parser rejects even though they look almost the same.

Where will you meet JSON at work?

APIs

Most services send and receive their data as JSON.

Structured data

Describing your pages to Google with JSON-LD inside the page.

Configuration

Many apps and tools keep their settings in JSON files.

Data export

Converting spreadsheets to JSON and back to move data between systems.

For structured data specifically, read our structured data guide and create it with the Schema Markup Generator.

From API to order notification: a real data journey

When a customer pays in your store, the payment gateway sends your site an automatic message called a webhook, usually text in this format containing the transaction ID, amount and status. Your site reads the message, updates the order, then sends similar data to the shipping system and a confirmation to the customer. None of these systems know each other, yet they understand each other because they exchange data in the same shape.

That's why understanding the format helps even if you're not a developer: when an integration fails, you can open the message log and read the reason yourself, such as a missing field or a text value where a number was expected, instead of waiting hours for a developer. We explain how these connections between systems are built in our business process automation guide.

Validate before you use it

Before you put a JSON file on your site or send it to another system:

Our formatter and validator tool finds the error and points to the line it's on, then re-indents the text so it's easy to read. If you want the official reference for the rules, they're documented in RFC 8259 and on json.org, which shows the syntax diagrams.

Mistakes that don't break the file but corrupt the data

Some mistakes don't make the file invalid, so it passes validation, yet they cause problems later:

Numbers written as strings. A price of "150" in quotes is treated as text, not a number, so sums or sorting may fail, or "1000" may sort before "200" because the comparison went character by character.

Dates in mixed formats. "5/3/2026" may mean 5 March or 3 May depending on the country. Agree on one clear format such as 2026-03-05, which systems understand and which sorts chronologically even as text.

Inconsistent field names. A field called phone in one file, mobile in another and Phone in a third makes integrations fragile. Agree on names and document them.

Sensitive data in exposed places. Configuration files containing API keys or passwords should never sit in a public folder on your site or in a shared repository.

When will you need this format day to day?

Even if you never write code, you'll meet it in practical situations: adding structured data to your site, as explained in our schema markup guide, exporting data from one system to import into another, reading error logs in automation tools, and configuring some plugins and services. Learning to read it takes about an hour, but it saves you a lot of dependence on others for simple problems. Start with a small file, try editing it and checking it with the validator, then move on to real files from your own systems.

Conclusion

JSON is a simple data language: objects, arrays and six value types, with strict rules, chiefly double quotes and no comments or trailing commas. Validate any file before using it, and you'll read what systems send with confidence. To understand the APIs that exchange JSON, read our tech stack guide. If you need your website connected to other systems, see our website development service.

Frequently asked questions

What is JSON?

A text format for exchanging data, written as key/value pairs inside curly braces, used by most APIs and apps because it's light and easy for both humans and machines to read.

What value types does JSON have?

Six types: a string in double quotes, a number, a boolean true or false, null, an object and an array.

Does JSON allow comments?

No. The standard allows neither comments nor a trailing comma after the last item, and either makes the file invalid for most systems.

How do I know if a JSON file is valid?

Paste it into a validator and formatter, which points to the line with the error and shows the file neatly formatted.

What's the difference between JSON and CSV?

CSV is a flat table of rows and columns, great for simple data such as a customer list you open in a spreadsheet. JSON describes nested data, such as an order containing several products each with their own properties, which is why APIs and apps use it.

Does JSON support Arabic text?

Yes. The standard uses UTF-8, which supports Arabic and every other language. If Arabic letters appear as strange symbols, the problem is usually that the file was saved or read with a different encoding, not the format itself.

Sources & references

  1. json.org — Introducing JSON
  2. RFC 8259 — The JSON Data Interchange Format
Ahmad Khreis

About the author

webmaster

I believe technology is useful when it solves a clear problem — not when it's adopted because it's trendy. AI is a powerful tool for speeding up research, writing, analysis and automation, but it needs human expertise to review, guide and verify accuracy. That's why I prefer to start by understanding the business and its goals, then choose the simplest solution that delivers a measurable result, and build audience trust with honest, useful content.

Reader rating
5.0(2)
Published articles
81
  • #JSON
  • #data formats
  • #APIs
  • #web development
Share

How would you rate this article?

Be the first to rate

Comments

No comments yet. Share your thoughts!

Leave a comment

Related articles