What Is JSON? A Clear Explanation With Examples

JSON (JavaScript Object Notation) is a lightweight text format for storing and exchanging data. It's used in virtually every web API, app configuration file, and data exchange system. Here's what you need to know.

NK
Nitin KaushikPublished 5 September 2025 · Updated 1 June 2026 · 8 min read

Advertisement

If you've worked with any modern API, app configuration file, or web service, you've encountered JSON. It's the lingua franca of data exchange on the internet — readable by both humans and machines, supported by every programming language, and simple enough to learn in 15 minutes. Here's everything you need to understand JSON.

What JSON Stands For

JSON stands for JavaScript Object Notation. Despite the name, JSON isn't exclusively tied to JavaScript — it's supported natively in Python, Java, C#, Go, Ruby, PHP, and every other mainstream language. The name comes from its syntax, which is directly derived from how objects and arrays are written in JavaScript.

Douglas Crockford formalized the JSON specification in the early 2000s, and it was standardized as ECMA-404 in 2013 and RFC 8259 in 2017. The simplicity of the format — just a few straightforward rules — is why it displaced XML as the dominant data exchange format for web APIs.

JSON Syntax and Structure

JSON has just six rules. Master these and you understand JSON completely:

  • Data is in name/value pairs: keys are always strings in double quotes, followed by a colon, then the value
  • Data is separated by commas
  • Objects are enclosed in curly braces: { }
  • Arrays are enclosed in square brackets: [ ]
  • Strings must use double quotes (not single quotes)
  • Trailing commas are not allowed (common mistake)

Valid JSON example

{ "name": "Alice", "age": 30, "isActive": true, "scores": [98, 87, 92], "address": { "city": "London", "country": "UK" }, "nickname": null }

Advertisement

JSON Data Types

JSON supports exactly six value types. Every valid JSON value is one of these:

JSON data types with examples

TypeExampleNotes
String"hello world"Must use double quotes
Number42 or 3.14 or -7Integer or float, no quotes
Booleantrue or falseLowercase only
NullnullLowercase only — represents absence of value
Object{"key": "value"}Collection of key-value pairs
Array[1, "two", true]Ordered list of values

Type gotchas

JSON has no Date type — dates are usually stored as ISO 8601 strings ("2025-06-13T10:30:00Z"). JSON has no undefined — use null to represent missing values. JSON numbers don't support Infinity or NaN.

JSON Objects and Arrays

JSON objects and arrays are the two container types. An object is an unordered collection of key-value pairs — similar to a dictionary or hash map. An array is an ordered list of values. Objects and arrays can be nested inside each other to any depth, allowing complex data structures.

A key distinction: object keys must be unique within the same object (duplicate keys are technically invalid JSON, though some parsers accept them). Array elements don't have keys — they're accessed by index. Arrays can contain any mix of JSON types including other objects and arrays.

Where JSON Is Used

  • REST APIs: nearly every web API sends and receives data in JSON format
  • Configuration files: package.json (Node.js), tsconfig.json, .eslintrc, appsettings.json
  • Databases: PostgreSQL (JSONB), MongoDB, and Firebase store data in JSON-compatible formats
  • Data storage: session storage, local storage in browsers, and simple flat-file databases
  • Data interchange: client-server communication, microservice APIs, webhook payloads
  • Environment configuration: many cloud services (AWS, Azure) use JSON for resource definitions

Format and Validate JSON Free

Beautify minified JSON, validate syntax, and identify errors. Runs in your browser.

Open JSON Formatter →

JSON vs XML

JSON replaced XML as the dominant web API format for several reasons:

JSON vs XML: practical differences

PropertyJSONXML
Syntax verbosityCompactVerbose (opening + closing tags)
ReadabilityHigh — less markup clutterLower — tags obscure content
Data typesBuilt-in (number, boolean, null)Everything is a string (by default)
Parsing speedFaster in most languagesSlower (larger documents)
Comments supportNo comments allowedYes — <!-- comment -->
Schema validationJSON SchemaXML Schema (XSD), DTD
NamespacesNoYes
Dominant use caseWeb APIs, config filesLegacy enterprise, SOAP, document formats

Common JSON Mistakes

  • Trailing commas: JSON doesn't allow a comma after the last item in an object or array
  • Single quotes: JSON requires double quotes for all strings — single quotes are invalid
  • Unquoted keys: unlike JavaScript objects, JSON keys must always be quoted strings
  • Comments: JSON has no comment syntax — // and /* */ are both syntax errors
  • Undefined values: undefined is a JavaScript concept; JSON doesn't have it. Use null instead
  • Numbers as keys: object keys must be strings — {42: 'answer'} is invalid JSON

Validate Your JSON Now

Paste JSON to check for syntax errors, missing quotes, or trailing commas. Free and instant.

Validate JSON →

Advertisement

Frequently Asked Questions

What does JSON stand for?

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

What is JSON used for?

JSON is used for data exchange between applications — primarily in web APIs (sending/receiving data), configuration files (package.json, tsconfig.json), database storage, and anywhere structured data needs to be transmitted or stored as text.

Is JSON the same as JavaScript?

No. JSON syntax is derived from JavaScript object literal syntax, but JSON is a standalone data format specification. JSON is more restrictive than JavaScript objects — it requires double-quoted string keys, has no undefined or function values, and doesn't allow comments.

What is the difference between JSON and XML?

JSON is more compact, easier to read, has native data types (numbers, booleans), and parses faster. XML supports comments, namespaces, and has a more complete schema validation system. JSON has replaced XML for most new web API development.

How do I validate JSON?

Use a JSON formatter/validator tool. Paste your JSON and the tool highlights syntax errors — missing quotes, trailing commas, unmatched brackets. Our free JSON Formatter validates as you type.

Does JSON support arrays?

Yes. JSON arrays are ordered lists of values enclosed in square brackets: [1, 'two', true, null, {}, []]. Array elements can be any valid JSON type including objects and nested arrays.

Can JSON have comments?

No. JSON does not support any comment syntax. If you need comments in a JSON-like config file, some tools support JSONC (JSON with Comments) as an extension, but standard JSON parsers will reject comments.

Related Tools