JSON (JavaScript Object Notation) is a lightweight text format for storing and exchanging structured data. It powers the vast majority of web APIs, most application config files, and countless databases. If you've ever seen a response from a REST API or opened a package.json file, you've read JSON. This guide explains exactly what JSON is, what the format looks like, and why it became the universal language of data interchange.
What Is JSON?
JSON stands for JavaScript Object Notation. It was created by Douglas Crockford in the early 2000s as a simpler alternative to XML for exchanging data between a web server and a browser. Despite the "JavaScript" in its name, JSON is language-independent — every major programming language has a built-in JSON parser.
The format is defined by two international standards: the IETF's RFC 8259 (history and key changes) and Ecma International's ECMA-404. Both say the same thing: JSON is a sequence of Unicode characters representing one of six data types, encoded in UTF-8.
The Six JSON Data Types
JSON supports exactly six value types. Understanding them is the foundation of understanding the JSON format.
1. Object
An unordered collection of key–value pairs wrapped in curly braces. Keys must be strings (double-quoted). Values can be any JSON type.
{
"name": "Alice",
"age": 30,
"active": true
}2. Array
An ordered list of values wrapped in square brackets.
["apple", "banana", "cherry"]3. String
A sequence of Unicode characters enclosed in double quotes. Single quotes are not valid JSON.
"Hello, world!"4. Number
An integer or floating-point number. JSON has no separate integer and float types — there is just number. No quotes, no hex literals, no NaN or Infinity.
42
3.14
-7
1.5e105. Boolean
Exactly true or false, lowercase. JSON does not accept True, False, yes, no, 1, or 0 as boolean values.
true
false6. Null
Represents the absence of a value. Written as lowercase null.
nullWhat is a JSON file? (and the .json file format)
A JSON file (sometimes mistyped as a jason file) is a plain text file that contains a single JSON value — most commonly an object or array. The .json file format is just UTF-8 text following RFC 8259, with the .json extension by convention. Because it is plain text, you don't need a special viewer to open it.
How to open a JSON file (or .json file): any text editor will do — VS Code, Notepad, TextEdit, Sublime, nano. The same question gets asked many ways — how to open json files, how to open a .json file, how do i open a json file, how do you open a json file, or simply open json file— and the answer is the same: open it as text. For a more readable view, paste the contents into the JSON Viewer for a collapsible tree, or into the JSON Fix tool to format it. On macOS and Windows, double-clicking a .json file usually opens it in your default text editor; if it tries to open in a browser you can right-click and choose "Open with" to pick an editor instead. No special unzip or extract step is needed — .json files are not archives.
How to create a JSON file (also asked as "how to make a json file"): open any text editor, write a single valid JSON value (an object, array, string, number, boolean, or null), and save it with the .json extension. That is the entire process — there is no header, no schema declaration, no required encoding marker beyond UTF-8. Programs read it as the json file format the moment the extension is recognised. A small json file example: { "name": "Ada", "active": true }.
What is JSON format? (and the related search, why files are stored in json format): JSON format is a small, language-independent text format for data — keys, values, arrays, and objects, with a fixed set of literal types. Files are stored in this format because the same document can be read by Python, Go, Java, JavaScript, Rust, and databases without translation — JSON is the lowest common denominator for moving structured data between systems.
// users.json
[
{ "id": 1, "name": "Alice", "role": "admin" },
{ "id": 2, "name": "Bob", "role": "editor" }
]Common JSON files you've likely already encountered:
package.json— Node.js project metadata and dependenciestsconfig.json— TypeScript compiler configurationsettings.json— VS Code user settingsmanifest.json— Browser extension or PWA manifest
What Is the JSON Data Format?
The JSON data format has a few strict rules that distinguish it from similar-looking JavaScript code:
- All keys must be double-quoted strings.
{ name: "Alice" }is a JavaScript object literal, not JSON. - Strings must use double quotes.
{ "name": 'Alice' }is invalid JSON. - No trailing commas.
{ "a": 1, }is invalid JSON. - No comments.
// commentand/* block comment */are not allowed in JSON. - No
undefined. JavaScript'sundefinedhas no JSON equivalent. Usenullinstead.
JSON vs. XML: Why JSON Won (xml vs json)
Is JSON the same as XML? No — both carry structured data, but the two formats are different in shape, size, and machinery. Before JSON took over, XML was the standard data interchange format. Here's the same data in both:
<!-- XML -->
<user>
<name>Alice</name>
<age>30</age>
</user>
// JSON
{ "name": "Alice", "age": 30 }JSON is more compact, easier for humans to read, and natively parseable in JavaScript without a third-party library. For most use cases — API responses, configuration, messaging — JSON requires significantly less bandwidth and less code than XML.
Where JSON Is Used
- REST APIs: The
Content-Type: application/jsonheader marks virtually every modern web API response. - Configuration files:
package.json,tsconfig.json,.eslintrc.json, AWS CloudFormation templates. - Databases: PostgreSQL, MySQL, MongoDB, and DynamoDB all support storing and querying JSON columns or documents natively.
- Log files: Structured logging (using JSON Lines) makes log data machine-parseable for aggregation tools like Elasticsearch.
- Inter-process communication: Microservices, message queues (Kafka, RabbitMQ), and serverless functions all use JSON as the default payload format.
JSON in Databases
Most modern databases can store and query JSON directly, so a document doesn't have to live in a separate document store to keep its structure:
- PostgreSQL — two types:
jsonstores the exact text;jsonbstores a binary, indexable representation. Query with->/->>for fields and@>for containment; index hot paths with a GIN index on thejsonbcolumn. - MongoDB — documents are JSON-like (BSON on disk). Field-level indexes and full aggregation pipelines work directly on the document shape.
- SQLite — the JSON1 extension (built in to modern SQLite) provides
json_extract,json_each, and generated columns indexed off JSON fields. - MySQL — a native
JSONcolumn type plus path expressions andJSON_TABLEfor joining JSON values as rows.
Two practical reminders for any of these: large integers can lose precision through the client driver, and the JSON spec doesn't define a canonical ordering of keys — if you need deterministic comparisons or hashing, use RFC 8785 (JCS).
Common JSON Errors
Even experienced developers write invalid JSON. The most common mistakes:
- Trailing commas after the last element
- Single quotes instead of double quotes
- Unquoted keys
- JavaScript comments inside JSON
- Python values like
True,False,None
If your JSON isn't parsing correctly, fix it instantly online — the tool automatically repairs these common issues and shows you exactly what was changed.
Parsing JSON in Code
Every major language includes built-in JSON support:
// JavaScript
const obj = JSON.parse('{"name":"Alice","age":30}');
console.log(obj.name); // "Alice"
# Python
import json
obj = json.loads('{"name":"Alice","age":30}')
print(obj['name']) # Alice
# Go
import "encoding/json"
var obj map[string]interface{}
json.Unmarshal([]byte(`{"name":"Alice","age":30}`), &obj)How to read json file python (or read json file in python): use json.load(open('data.json')) for a file path, or json.loads(text) when the JSON is already a string. Both raise json.JSONDecodeError on syntax errors.
The choice of json over xml in modern systems usually comes down to bytes-on-the-wire and parser support — every language has native JSON support, while XML still typically needs a third-party library.
Common JSON Variants You'll Encounter
Strict JSON is the baseline, but a few closely-related dialects show up regularly:
- JSONC (JSON with Comments) — JSON that allows
//and/* */comments and trailing commas.tsconfig.jsonand VS Codesettings.jsonuse it. Standard parsers reject it; use a JSONC-aware parser or strip comments first. - NDJSON / JSON Lines — one JSON value per line, separated by
\n. Used for streaming logs, ML datasets, and bulk APIs. Parse each line withJSON.parse, not the whole file at once. - JSON Pointer (RFC 6901) — a path syntax for addressing a value inside a document, e.g.
/users/0/name. It's the path format used by JSON Patch and JSON Schema's$ref.
Frequently Asked Questions
What does JSON stand for?
JSON stands for JavaScript Object Notation. Despite the name it's language-independent — every major language can read and write it — and it's defined by RFC 8259 and ECMA-404.
What are the data types in JSON?
Six: string, number, boolean, null, object, and array. There's no separate integer type, no date type, and no undefined. See JSON format examples for each one in context.
Is JSON the same as a JavaScript object?
No. JSON is a text format with strict rules (double-quoted keys, no trailing commas, no comments); a JavaScript object literal is code that's far more permissive. See JSON vs JavaScript objects.
How do I check that JSON is valid?
Parse it with JSON.parse() (it throws on invalid input) or follow How to Validate JSON and run it through a validator. To enforce structure and types, describe it with JSON Schema.
Tools for Working with JSON
- JSON Fix — validate, repair, and format invalid JSON instantly
- What Is JSON Schema? — describe and validate the structure of JSON data
- How to Format JSON — pretty-print JSON in JavaScript, Python, the command line, or your browser
- JSON Format Examples — copy-pasteable examples covering every data type and real-world pattern
- JSON Diff — compare two JSON documents and see what changed
- YAML to JSON — convert YAML configuration to JSON format