What is JSON? Complete Guide for Beginners []

JSON (JavaScript Object Notation) is a lightweight, text-based data interchange format. This JSON tutorial for beginners covers everything you need to know: JSON uses key-value pairs with curly braces {} and square brackets []. It's language-independent and readable by both humans and machines, making it the standard format for web APIs and data exchange.

What Does JSON Stand For?

JSON stands for "JavaScript Object Notation." Despite the name, JSON is completely language-independent and works with almost all programming languages including Python, Java, C#, PHP, Ruby, Go, and many more.

JSON was created by Douglas Crockford in 2001. The first JSON message was sent in April 2001, and the format quickly gained popularity as a lightweight alternative to XML for data exchange. Today, JSON is standardized in two specifications:

  • RFC 8259 – Published by IETF in December 2017, the current Internet Standard
  • ECMA-404 – Published by Ecma International in October 2013
Key fact: While JSON originated from JavaScript, it became a universal data format because of its simplicity and readability. The official MIME type is application/json and the file extension is .json. See how JSON compares to YAML in our YAML vs JSON comparison.

What Coding Language Does JSON Use?

JSON is not tied to any specific programming language. While it was derived from JavaScript syntax, JSON is a text format that any language can parse and generate. It's language-independent by design.

Most modern programming languages have built-in or standard library support for JSON:

Language JSON Support
JavaScript Built-in: JSON.parse(), JSON.stringify()
Python Standard library: import json
Java Libraries: Jackson, Gson, org.json
C# Built-in: System.Text.Json, Newtonsoft.Json
PHP Built-in: json_encode(), json_decode()
Go Standard library: encoding/json

Is JSON Python or Java?

JSON is neither Python nor Java—it's a data format, not a programming language. JSON was derived from JavaScript syntax but is completely language-independent. Both Python and Java (and virtually all other programming languages) can read and write JSON data.

Think of JSON like a common language for data: just as English might be used as a common language between people who speak different native languages, JSON is a common format for exchanging data between programs written in different programming languages.

Important distinction: JSON describes data, not instructions. You cannot write programs in JSON—you can only store and transfer structured data. Need to convert JSON to YAML? See our Python, JavaScript, or Java conversion guides, or try our online JSON to YAML converter.

JSON Syntax Basics

JSON syntax is simple and consists of just two structures: objects and arrays.

Objects (Key-Value Pairs)

Objects are wrapped in curly braces {} and contain key-value pairs:

{
  "name": "John Doe",
  "age": 30,
  "isActive": true
}

Arrays (Ordered Lists)

Arrays are wrapped in square brackets [] and contain ordered values:

{
  "fruits": ["apple", "banana", "orange"],
  "numbers": [1, 2, 3, 4, 5]
}

Data Types

JSON supports six data types:

  • String – Text in double quotes: "hello"
  • Number – Integer or decimal: 42, 3.14
  • Booleantrue or false
  • Null – Empty value: null
  • Object – Nested {} structure
  • Array – Nested [] structure

Nested Structures

Objects and arrays can be nested to create complex data structures:

{
  "person": {
    "name": "Jane Smith",
    "address": {
      "street": "123 Main St",
      "city": "New York"
    },
    "phones": [
      {"type": "home", "number": "555-1234"},
      {"type": "work", "number": "555-5678"}
    ]
  }
}

What Does {} Mean in JSON?

Curly braces {} in JSON represent an object (also called a dictionary, map, or hash in other languages). An object contains zero or more key-value pairs.

Each key-value pair follows these rules:

  • The key must be a string in double quotes
  • A colon : separates the key from the value
  • The value can be any valid JSON data type
  • Multiple pairs are separated by commas ,
{
  "key1": "value1",
  "key2": 42,
  "key3": true,
  "key4": null,
  "key5": {"nested": "object"},
  "key6": [1, 2, 3]
}

Similarly, square brackets [] represent an array—an ordered list of values separated by commas.

What is Not Allowed in JSON?

JSON has strict syntax rules designed to keep it simple and fast to parse. Here's what's not allowed:

Not Allowed Why Alternative
Comments Keep format simple Use a "_comment" key or YAML
Trailing commas Parsing simplicity Remove last comma
Single quotes Consistency Use double quotes only
Unquoted keys Consistency Always quote keys
undefined, NaN, Infinity Language-specific Use null or omit
Functions Data only, no code Not possible
Date objects No built-in type Use ISO string: "2025-12-17"
Common mistake: Trailing commas after the last item cause parsing errors. Always remove the comma after the final element.

Is JSON Binary or Text?

JSON is a text-based format, not binary. It's stored and transmitted as human-readable text, typically encoded in UTF-8 (which RFC 8259 mandates for network transmission).

This text-based nature has trade-offs:

  • Advantages: Easy to read, debug, and edit by humans
  • Disadvantages: Larger file sizes and slower parsing than binary formats

For applications requiring better performance or smaller sizes, binary alternatives include:

  • MessagePack – Binary JSON-like format
  • Protocol Buffers – Google's binary format
  • BSON – Binary JSON used by MongoDB

For binary data within JSON (like images), use Base64 encoding to represent binary as a text string.

JSON Example

Here's a complete, real-world JSON example—a typical API response:

{
  "status": "success",
  "data": {
    "user": {
      "id": 12345,
      "username": "johndoe",
      "email": "[email protected]",
      "isVerified": true,
      "createdAt": "2025-01-15T10:30:00Z",
      "profile": {
        "firstName": "John",
        "lastName": "Doe",
        "avatar": "https://example.com/avatar.jpg",
        "bio": null
      },
      "roles": ["user", "moderator"],
      "settings": {
        "notifications": true,
        "theme": "dark",
        "language": "en"
      }
    }
  },
  "meta": {
    "requestId": "abc-123-xyz",
    "responseTime": 42
  }
}

This example demonstrates objects, arrays, strings, numbers, booleans, null values, and nested structures.

Need to convert JSON to YAML?

Use our free online converter to instantly transform JSON to YAML or vice versa.

Open Converter Tool →

What is JSON Used For?

JSON is used wherever structured data needs to be stored or transmitted. Common use cases include:

  • Web APIs (REST) – JSON is the standard format for REST API requests and responses, used by most web services.
  • Configuration files – Many applications use JSON for settings (package.json, tsconfig.json, etc.).
  • Data storage – NoSQL databases like MongoDB store data in JSON-like format (BSON).
  • Data exchange – Sending data between client and server, between microservices, or between different systems.
  • Browser storage – LocalStorage and SessionStorage APIs use JSON for persisting data in the browser.
  • Logging – Structured logging often uses JSON for machine-parseable log entries.

Frequently Asked Questions

What does JSON stand for?

JSON stands for JavaScript Object Notation. Despite the name, JSON is language-independent and works with almost all programming languages. It was created by Douglas Crockford in 2001 and standardized as RFC 8259 and ECMA-404.

What coding language does JSON use?

JSON is not tied to any specific programming language. While it originated from JavaScript, JSON is a text format that any language can parse and generate. Python has the json module, Java has Jackson and Gson, and most languages have built-in support.

Is JSON Python or Java?

JSON is neither Python nor Java—it's a data format, not a programming language. JSON was derived from JavaScript syntax but is completely language-independent. Both Python and Java can read and write JSON data.

What is not allowed in JSON?

JSON does not allow: comments, trailing commas, single quotes (must use double quotes), undefined/NaN/Infinity values, functions, and unquoted keys. Dates must be strings. These restrictions keep JSON simple and fast to parse.

Is JSON binary or text?

JSON is a text-based format, not binary. It's stored as human-readable text encoded in UTF-8, making it easy to debug but less efficient than binary formats. For binary data, use Base64 encoding or alternatives like MessagePack.

What does {} mean in JSON?

Curly braces {} in JSON represent an object (dictionary/map). An object contains key-value pairs where each key is a quoted string, followed by a colon, then a value. Multiple pairs are separated by commas.

Is JSON easy to learn?

Yes, JSON is very easy to learn. The syntax consists of just objects {}, arrays [], and a few data types. Most developers can understand JSON in 15-30 minutes. The main rules: use double quotes, no trailing commas, and no comments.

What is JSON used for?

JSON is primarily used for web APIs (REST), configuration files (package.json), data storage, data exchange between systems, and NoSQL databases like MongoDB. It's the standard format for web applications.