JSON BasicsJSON TutorialWeb Development

What is JSON? A Complete Beginner's Guide

JSON Validator Online

JSON (JavaScript Object Notation) is the backbone of modern web data exchange. Whether you are building an API, reading data from a third-party service, or storing configuration settings, you will encounter JSON constantly as a developer.

In this guide, you will learn exactly what JSON is, how to read and write it, what rules it follows, and why it has become the standard data format for the web.

Ready to validate your JSON as you learn? Use our free json validator online to check your JSON syntax instantly.


What is JSON?

JSON stands for JavaScript Object Notation. It is a lightweight, text-based format for storing and transporting data. Despite having “JavaScript” in its name, JSON is completely language-independent it can be used with Python, Java, PHP, Ruby, Go, and virtually every programming language in existence.

JSON was created by Douglas Crockford in the early 2000s as a simpler alternative to XML. It quickly became the dominant data format for web APIs and configuration files because it is:

  • Human-readable easy to read and write by hand
  • Machine-parseable straightforward for computers to parse and generate
  • Lightweight minimal syntax overhead compared to XML
  • Universal supported by every major programming language

JSON Syntax Rules

JSON has six core data types and a strict set of syntax rules. Breaking any of these rules will make your JSON invalid.

Strings

Strings must always be wrapped in double quotes single quotes are not allowed.

"name": "John Doe"

Numbers

Numbers can be integers or floats. No quotes needed.

"age": 30,
"price": 19.99

Booleans

Only lowercase true or false are valid.

"isActive": true,
"isDeleted": false

Null

Use lowercase null to represent an empty or missing value.

"middleName": null

Arrays

Arrays are ordered lists of values, enclosed in square brackets.

"colors": ["red", "green", "blue"]

Objects

Objects are collections of key-value pairs, enclosed in curly braces. Keys must always be strings in double quotes.

{
  "user": {
    "id": 1,
    "name": "Alice"
  }
}

A Complete JSON Example

Here is a real-world JSON structure representing a user profile:

{
  "id": 101,
  "name": "Alice Johnson",
  "email": "alice@example.com",
  "age": 28,
  "isPremium": true,
  "address": {
    "street": "123 Main St",
    "city": "New York",
    "country": "USA"
  },
  "tags": ["developer", "designer"],
  "lastLogin": null
}

Every element here follows strict JSON rules quoted keys, proper value types, and correct nesting.

Why JSON is the Standard for Web APIs

Before JSON, XML was the dominant format for data exchange. JSON won for several reasons:

FeatureJSONXML
ReadabilityHighMedium
File sizeSmallLarge
Parsing speedFastSlower
Native JS supportYesRequires parsing
Learning curveLowMedium

When you call any modern REST API whether it is Twitter, Stripe, OpenAI, or GitHub the response comes back as JSON. It is the universal language of web services.

Common JSON Mistakes

Even experienced developers make JSON errors. Here are the most common ones:

1. Using single quotes

// INVALID
{ 'name': 'Alice' }

// VALID
{ "name": "Alice" }

2. Trailing commas

JSON does not allow a trailing comma after the last item in an object or array.

// INVALID
{
  "name": "Alice",
  "age": 28,
}

// VALID
{
  "name": "Alice",
  "age": 28
}

3. Undefined values

undefined is a JavaScript concept it does not exist in JSON. Use null instead.

// INVALID
{ "value": undefined }

// VALID
{ "value": null }

4. Comments

JSON does not support comments. If you need comments in a config file, consider using JSONC or YAML instead.

// INVALID
{
  // This is a user object
  "name": "Alice"
}

How to Validate JSON

When working with JSON, syntax errors are easy to introduce and can be frustrating to debug. The fastest way to check your JSON is to use a dedicated validator tool.

Our json validator online gives you instant feedback:

  • Highlights the exact line where an error occurs
  • Shows a clear error message explaining what went wrong
  • Formats and prettifies valid JSON automatically
  • Works entirely in your browser no data is ever sent to a server

JSON vs JavaScript Objects

JSON looks very similar to JavaScript objects, but they are not the same thing.

A JavaScript object can have:

  • Unquoted keys: { name: "Alice" }
  • Functions as values
  • undefined values
  • Trailing commas (in modern JS)

JSON requires:

  • All keys in double quotes: { "name": "Alice" }
  • Only the six supported data types
  • No trailing commas
  • No comments

When you call JSON.parse() in JavaScript, you convert a JSON string into a JavaScript object. When you call JSON.stringify(), you go the other direction.

JSON in Practice

Here are the most common places you will encounter JSON as a developer:

  • REST APIs nearly every API returns JSON responses
  • Config files package.json, tsconfig.json, .eslintrc.json
  • Databases MongoDB, Firestore, and PostgreSQL’s JSONB column
  • Local storage storing structured data in the browser
  • CI/CD pipelines GitHub Actions, build configs

Conclusion

JSON is one of the most important data formats in modern software development. Once you understand its six data types and strict syntax rules, reading and writing JSON becomes second nature.

The key things to remember:

  • Always use double quotes for strings and keys
  • No trailing commas
  • No comments
  • Only six valid data types: string, number, boolean, null, array, object

Whenever you are unsure whether your JSON is valid, run it through our json validator online for an instant check it is free, fast, and requires no signup.

Ready to validate your JSON? Use our free json validator online no signup required, no data stored, instant results right in your browser.

Try JSON Validator Online →