What is JSON? A Complete Guide to JavaScript Object Notation (2026)

Published April 2, 2026 · 8 min read

JSON (JavaScript Object Notation) is a lightweight, text-based data format that has become the de facto standard for data exchange on the web. Whether you're building a REST API, configuring a modern application, or storing data in a NoSQL database, you'll encounter JSON.

In this guide, we'll explain everything you need to know about JSON — from basic syntax to advanced use cases — with clear examples you can try right now in our free JSON formatter.

Table of Contents

  1. What is JSON?
  2. JSON Syntax Rules
  3. JSON Data Types
  4. JSON Examples
  5. JSON vs XML
  6. Common Uses of JSON
  7. How to Format JSON
  8. Frequently Asked Questions

1. What is JSON?

JSON stands for JavaScript Object Notation. It was originally derived from JavaScript (specifically, the object literal syntax), but it is now a language-independent data format specified by RFC 8259 and standardized as ECMA-404.

The key characteristics of JSON:

2. JSON Syntax Rules

JSON has a simple, strict syntax with only a few rules:

Rule 1: Key-Value Pairs

Data is stored as key-value pairs. Keys are always strings in double quotes. Values can be strings, numbers, booleans, arrays, objects, or null.

{ "name": "John", "age": 30 }

Rule 2: Double Quotes Only

Strings and keys must use double quotes. Single quotes are not allowed in valid JSON.

// ❌ Invalid
{ 'name': 'John' }

// ✅ Valid
{ "name": "John" }

Rule 3: No Trailing Commas

Unlike JavaScript, JSON does not allow trailing commas after the last item in an object or array.

// ❌ Invalid
{ "name": "John", }

// ✅ Valid
{ "name": "John" }

Rule 4: No Comments

Standard JSON does not support comments. If you need comments, consider JSONC (JSON with Comments) used in VS Code settings.

3. JSON Data Types

JSON supports exactly six data types:

Type Example Description
string"hello"Text in double quotes
number42, 3.14Integer or float (no quotes)
booleantrue, falseLowercase, no quotes
nullnullEmpty value (lowercase)
array[1, 2, 3]Ordered list of values
object{"a": 1}Unordered key-value pairs

4. Real-World JSON Examples

Example: User Profile

{
  "id": 12345,
  "username": "johndoe",
  "email": "john@example.com",
  "isActive": true,
  "roles": ["admin", "editor"],
  "profile": {
    "firstName": "John",
    "lastName": "Doe",
    "avatar": null
  }
}

Example: API Response

{
  "status": 200,
  "message": "Success",
  "data": {
    "products": [
      {"id": 1, "name": "Widget", "price": 9.99},
      {"id": 2, "name": "Gadget", "price": 24.99}
    ],
    "total": 2,
    "page": 1
  }
}

Try pasting these examples into our JSON Formatter to see them beautifully formatted!

5. JSON vs XML

Feature JSON XML
SyntaxSimple, minimalVerbose, tag-based
Size~30% smallerLarger due to tags
Parsing SpeedFasterSlower
Data TypesBuilt-in (6 types)All strings
CommentsNot supportedSupported
Best ForAPIs, config, dataDocuments, mixed content

6. Common Uses of JSON in 2026

7. How to Format JSON

There are several ways to format (beautify) JSON:

Online Tool (Easiest)

Use our free JSON Formatter — just paste your JSON and click "Format".

Command Line

# Python
python3 -m json.tool data.json

# jq
jq '.' data.json

# Node.js
node -e "console.log(JSON.stringify(JSON.parse(require('fs').readFileSync(0)),null,2))" < data.json

In Code

// JavaScript
const formatted = JSON.stringify(data, null, 2);

// Python
import json
formatted = json.dumps(data, indent=2)

8. Frequently Asked Questions

What does JSON stand for?

JSON stands for JavaScript Object Notation. Despite the name, it's a language-independent data format used by virtually every programming language.

Is JSON the same as JavaScript objects?

No. JSON is a text format (a string). JavaScript objects are in-memory data structures. JSON has stricter rules: no trailing commas, no single quotes, no comments, and keys must be in double quotes.

Can JSON contain functions?

No. JSON only supports primitive data types (string, number, boolean, null) and structured types (array, object). Functions, dates, and undefined are not valid JSON values.

What's the maximum size of a JSON file?

The JSON specification does not define a maximum size. Practical limits depend on the parser and available memory. Most browsers can handle JSON files up to several hundred megabytes.

How do I validate JSON?

Paste your JSON into our JSON Formatter and click "Validate". If there are syntax errors, the tool will tell you exactly what's wrong and where.

🛠️ Try It Now

Paste your JSON and format it instantly

Open JSON Formatter →