📖 What is a JSON File?
A JSON file stores structured data as plain text. The name stands for JavaScript Object Notation, and the file uses the .json extension. It holds data as a set of name and value pairs and ordered lists, in a form that is easy for people to read and simple for programs to parse.
JSON came out of JavaScript, where the syntax matches the way objects are written, but it is now language independent. Almost every programming language can read and write it, which is why JSON became the common tongue for moving data between systems, from web APIs to configuration files.
Key Characteristics
- Plain text, readable in any editor
- Name and value pairs, grouped in objects
- Language independent, read by nearly everything
- Strict syntax, double quotes and no trailing commas
What It Stores
- Objects, collections of key and value pairs
- Arrays, ordered lists of values
- Values, strings, numbers, booleans and null
- Nested data, objects and arrays inside each other
📍 Where You Meet JSON Files
You run into JSON far more often than you might expect, usually without opening the file directly. It quietly carries data behind a lot of everyday software.
Web APIs
Most web services send and receive data as JSON, so it is the format behind countless apps and sites.
Config Files
Many tools keep their settings in JSON, from code editors to build systems like package.json.
Data Export
Databases and apps export records as JSON because almost anything can read it back in.
NoSQL Storage
Document databases store records in a JSON-like shape, so the format maps straight onto how data lives.
⚡ Quick Facts
| File Extension | .json |
| Full Name | JavaScript Object Notation |
| Category | Structured data, text |
| MIME Type | application/json |
| Encoding | UTF-8 |
| Standardised By | RFC 8259 and ECMA-404 |
| Coined By | Douglas Crockford, around 2001 |
| Data Types | String, number, boolean, null, object, array |
| Comments | Not allowed |
| Related Extensions | .jsonl, .geojson, .json5, .jsonld |
🔤 JSON Syntax and Structure
JSON is built from two structures. An object is a set of name and value pairs wrapped in curly braces, and an array is an ordered list of values wrapped in square brackets. Everything else nests inside those two.
{
"name": "Ada Lovelace",
"active": true,
"age": 36,
"skills": ["maths", "logic"],
"address": { "city": "London" }
}
The rules are strict. Names and string values use double quotes, pairs are separated by commas, and the last item in an object or array must not have a trailing comma. That strictness is what lets any program read a JSON file the same way.
🧩 The Six JSON Data Types
Every value in a JSON file is one of six types. Three are simple values, and two are the containers that give JSON its shape, plus the empty value null.
| Type | Example | Notes |
|---|---|---|
| String | "hello" | Text in double quotes |
| Number | 42, 3.14 | Integer or decimal, no quotes |
| Boolean | true, false | Lower case, no quotes |
| Null | null | An empty or missing value |
| Object | { "k": "v" } | Name and value pairs in braces |
| Array | [1, 2, 3] | Ordered list in square brackets |
🔎 The Anatomy of a JSON File
Labelling the parts of a small JSON file makes the structure click. Here is how the pieces fit together.
💻 How to Open a JSON File
Because a JSON file is only text, anything that displays text will open it. What changes is how easy the file is to read and check.
Code editors
Visual Studio Code and similar editors colour the syntax, fold sections and flag errors as you type. They are the easiest way to read or edit a JSON file of any size.
Browsers and viewers
Web browsers display a JSON file and let you expand and collapse it. A dedicated JSON viewer does the same without installing anything, which is handy for a quick look. Univik's File Viewer opens files in the browser.
⚔️ JSON vs XML and YAML
JSON, XML and YAML all carry structured data, and they trade off differently between how easy they are to read and how strict they are. The diagram shows the same data in JSON and XML.
| Format | Readable | Verbose | Comments | Best For |
|---|---|---|---|---|
| JSON | ✓ High | ✓ Compact | ✗ No | Data exchange, APIs |
| XML | ~ Medium | ✗ Heavy tags | ✓ Yes | Documents, mixed content |
| YAML | ✓ Very high | ✓ Minimal | ✓ Yes | Config files |
🔀 JSON Variants and Related Extensions
Several formats build on JSON for particular jobs, each with its own extension while keeping the familiar syntax at the core.
.jsonl | JSON Lines, one JSON object per line, handy for streaming and large logs. |
.geojson | JSON for geographic data such as points, lines and shapes on a map. |
.json5 | A relaxed superset that allows comments and trailing commas for human editing. |
.jsonld | JSON for Linked Data, used to describe structured data on web pages. |
.topojson | A compact GeoJSON variant that encodes shared boundaries once. |
⚠️ Common JSON Errors
When a JSON file will not parse, the cause is nearly always a small syntax slip. These are the usual culprits.
Trailing comma
A comma after the last item in an object or array is invalid. Remove it and the file parses.
Single quotes
JSON needs double quotes on names and strings. Single quotes are a common cause of failure.
Comments left in
Standard JSON has no comments. A // or /* */ left in the file stops it parsing.
Missing bracket
An unclosed brace or bracket breaks the structure. A validator points to the spot.
❓ Frequently Asked Questions
A JSON file is plain text, so any text editor opens it: Notepad on Windows, TextEdit on Mac, or the default text app on Linux. A code editor such as Visual Studio Code or Notepad++ is better, because it colour-codes the structure and flags errors. A web browser will also display the contents. To make a dense file readable, open it in a JSON formatter, which indents it into a clear tree.
JSON stands for JavaScript Object Notation. The name reflects that its syntax comes from the way JavaScript writes objects and arrays. Despite the name, JSON is not tied to JavaScript. It is a language-independent data format that almost every programming language can read and write.
Yes. A JSON file holds data only, with no code that can run, so opening one in a text or code editor cannot execute anything. The one caution is a historical practice of passing JSON straight to a JavaScript eval() call, which is unsafe. Modern code uses a proper JSON parser instead, and simply viewing a .json file carries no such risk.
No. Standard JSON, as defined by RFC 8259, does not allow comments, and a strict parser rejects any it finds. If you need comments in a configuration file, two options work. Use JSON5, an extension that allows them and uses the .json5 extension, or switch that file to YAML, which supports comments and reads most JSON as valid.
JavaScript is a programming language that runs code. JSON is a data format that borrows JavaScript's notation for objects and arrays but nothing else. JSON has no functions, no variables and no logic, and its rules are stricter, requiring double quotes and forbidding trailing commas and comments. A JSON file describes data. A JavaScript file describes behaviour.
The official media type is application/json. Older types such as text/json and application/x-javascript exist but are obsolete and should not be used. When a server sends JSON, it sets the Content-Type header to application/json so the receiving program knows how to read it.
Almost always a small syntax slip. The common causes are a trailing comma after the last item, single quotes instead of double, an unquoted key, a leftover comment or a stray character. Paste the file into a JSON validator and it names the exact line, which usually makes the fix obvious.
Excel imports JSON through Power Query. Open Excel, go to the Data tab, choose Get Data, then From File and From JSON, and pick your file. Excel opens the Power Query Editor, where you turn the records into a table and expand the columns you need before loading them into a sheet. This suits flat, list-style data. Deeply nested or very large JSON files are slower in Excel, so a code editor or JSON viewer is often easier for those.
Open the file in a code editor such as Visual Studio Code, make your changes and save it with the .json extension in UTF-8 encoding. Keep the syntax strict, which means double quotes on keys and strings, no trailing commas and no comments. Before saving, run the file through a validator or let the editor check it, so a small slip does not stop the next program from reading it.
📝 Summary
A JSON file stores structured data as plain text in JavaScript Object Notation, using the .json extension. It holds objects of name and value pairs and arrays of values, in six data types, and follows strict syntax with double quotes and no trailing commas or comments. Coined by Douglas Crockford around 2001 and standardised as RFC 8259, JSON is read by nearly every language, which made it the standard for web APIs, config files and data export. Any text editor will show one, though a code editor such as Visual Studio Code makes it far easier to read and check, and a validator pinpoints the problem when a file will not parse.