A JSON file is a plain-text file that stores structured data — settings, lists, API responses, saved game state — in a format both people and programs can read. It always has the .json extension, and inside it you will find objects and arrays made of keys, values, strings, and numbers. If you have ever opened a package.json or downloaded data from an API, you have already met one.
Here is the short version: a JSON file is just text, so any text editor can open it, but the text has to follow strict rules. A single misplaced comma breaks the whole file. This guide shows you what a JSON file looks like, how to open and read one, how to edit it without breaking it, and how to tell it apart from CSV, XML, and JSONL.
What a JSON File Looks Like
The easiest way to understand JSON is to look at a real one. This is a small settings file for a fictional weather app, with a name, a city, a list of favourite places, and a few preferences:
{
"app": "Weather Now",
"version": 2,
"city": "Austin",
"units": "celsius",
"alerts": true,
"favourites": ["Dallas", "Houston", "San Antonio"],
"refreshMinutes": 30,
"api": {
"baseUrl": "https://api.example.com",
"timeoutSeconds": 10
}
}
Everything in the file is either a key with a value, like "city": "Austin", or a container holding more values. The outer braces mark an object. Inside it, "favourites" holds an array — an ordered list in square brackets — and "api" holds a nested object, an object inside an object. Nesting like this is how JSON represents real-world structure without a database.
Notice what is not in the file: no comments, no trailing commas, and every key in double quotes. Those are not style choices. They are rules of the format, and breaking any of them makes the file invalid. That strictness is also the point: because the rules are simple and fixed, any language — JavaScript, Python, PHP, Go — can read the same file the same way.
The Six Building Blocks of JSON
JSON has only six data types, and every value in every JSON file is one of them. Learn these six and you can read any JSON file, no matter how large it is.
| Data type | Example | Notes |
|---|---|---|
| Object | {"key": "value"} |
Key-value pairs in braces; keys are always double-quoted strings |
| Array | [1, 2, 3] |
Ordered list in brackets; items can be any mix of types |
| String | "hello" |
Double quotes only; single quotes are never valid |
| Number | 42, 3.14 |
No leading zeros, no NaN, no Infinity |
| Boolean | true, false |
Lowercase only |
| Null | null |
Means "no value"; lowercase only |
The six types combine freely. An array can hold objects, an object can hold arrays, and either can nest as deep as the data needs. That is why a single format covers everything from a two-line config file to a million-row data export: the vocabulary never changes, only the size does.
JSON was introduced by Douglas Crockford in the early 2000s and later standardized as ECMA-404 and RFC 8259. The format's own home page, json.org, still describes it in one sentence: a lightweight data-interchange format that is easy for humans to read and write, and easy for machines to parse and generate. Twenty years on, that description still holds.
How to Open a JSON File
Because a JSON file is plain text, you already have several ways to open one. The right choice depends on what you want to do with it: glance at it, read it properly, or edit it.
Any text editor works for a quick look. Notepad on Windows, TextEdit on a Mac, or any code editor will open a .json file and show its contents. For a small file this is enough. For a large one, a plain editor shows you a wall of text, possibly all on one line if the file was minified, which is hard to read and easy to break by accident.
A code editor is the better default. VS Code opens JSON files with syntax highlighting and collapsible sections, so you can fold away parts you do not need and spot a missing bracket at a glance. It also warns you about syntax errors as you type, which is the single most useful feature when you are editing by hand.
Your browser can open a JSON file too: drag the file into a browser window and it displays the contents, often with its own collapsible viewer. That is handy for a quick read, but a browser will not let you edit the file, and it will not save your changes.
For reading and fixing a file, a dedicated tool is the fastest route. Paste the contents into our free JSON Formatter and it re-indents the file into a readable structure, highlights errors with a line number, and lets you copy the cleaned-up result. If you are unsure whether you need a formatter or a validator, our comparison of a formatter versus validator explains which job each tool does.
How to Read a JSON File
Reading JSON is a matter of following the nesting. Start at the outer braces and read each key in turn. When a value is an object or an array, read inside it before moving on. Take the weather-app example above: the top level says this is version 2 of "Weather Now", set to Austin in Celsius, with alerts on and a 30-minute refresh.
The favourites array lists three cities, and the nested api object holds the server address and a 10-second timeout.
Two habits make reading easier. First, format the file before you read it — a minified file on one line hides its structure, and a formatted file shows it. Second, collapse sections you do not need. In a code editor, clicking the fold marker next to a large array hides hundreds of lines you already understand, so the part you care about stays visible.
Watch for the same traps when reading as when writing. A value that looks like a number may be a string — "42" in quotes is text, while 42 without quotes is a number, and a program will treat them differently. Dates are another common surprise: JSON has no date type, so dates appear as strings like "2026-11-15", and each system decides how to interpret them.
JSON File Viewer vs Editor: Which Do You Need?
The terms sound similar, but a JSON file viewer and a JSON editor do different jobs, and picking the wrong one wastes time. A viewer shows you the structure — collapsible trees, search, and a clean layout — but does not change the file. An editor lets you change values, add keys, and save the result.
If you are inspecting an API response or checking what a config file contains, a viewer is enough. Our JSON Formatter works as a viewer: paste the file, and it presents the structure with errors flagged. If you are changing settings or fixing a broken file, use a code editor like VS Code, which checks your syntax as you type and saves the file in place.
The best JSON viewer for most people is the one already on their machine: a browser for a quick look, VS Code for anything serious, and a formatter tool when the file arrives as one long line. You do not need a specialist app for JSON. The format is deliberately simple, and the tools that read it are everywhere.
JSON vs CSV, XML, YAML, and JSONL
JSON is not the only way to store structured data, and each alternative fits a different shape of problem. The table below is the decision shortcut; the rule of thumb is to match the format to the shape of your data.
| Format | Best for | Main weakness |
|---|---|---|
| JSON | Nested data, APIs, configs | Verbose for flat tables; no comments |
| CSV | Flat tables, spreadsheets | No nesting; no data types |
| XML | Documents with mixed content | Verbose; harder to read |
| YAML | Human-written configs | Indentation errors; ambiguous types |
| JSONL | Streaming, log files | One object per line; not one document |
CSV wins for flat, spreadsheet-shaped data — rows and columns with no nesting — because it is smaller and every spreadsheet app opens it. JSON wins the moment the data nests: a user with an address, a list of orders, and settings per order is awkward in CSV and natural in JSON.
XML is the older alternative, still common in enterprise and document formats. It handles mixed content — text with markup inside it — better than JSON, but it is far more verbose, and most new APIs chose JSON years ago. YAML is popular for configuration files because it is easy to write by hand, but its indentation rules cause exactly the kind of silent errors JSON's brackets avoid.
JSONL deserves a special mention because it is often confused with JSON. A JSONL file is a series of JSON objects, one per line, with no outer array and no commas between them. Each line is valid JSON on its own. It is the format of choice for log files and streaming data, where you want to read one record at a time without loading the whole file.
Common Mistakes That Break a JSON File
Most broken JSON files fail for one of four reasons, and all four are easy to spot once you know them. A trailing comma after the last item in an object or array is the most common: {"a": 1,} is invalid, because the comma promises another item that never comes.
Single quotes are the second. JSON strings must use double quotes, so {'a': 1} fails even though it looks fine to a JavaScript developer. Third, unquoted keys fail for the same reason: {a: 1} is JavaScript, not JSON. Fourth, comments are not allowed — a // note inside a JSON file makes it invalid, which surprises people coming from JavaScript or YAML.
When a file fails, do not scan it by eye. Paste it into a validator and read the error: it will name the line and column where the parser gave up, which is usually within a line or two of the actual mistake. Our complete guide to JSON syntax walks through each error type with examples, including how to read the error messages validators produce.
Frequently Asked Questions
What is a JSON file used for?
JSON files store structured data that programs need to read: application settings, API responses, data exports, and saved state. Configuration files like package.json, tsconfig.json, and .vscode/settings.json are JSON files, and most web APIs return their data as JSON too.
How do I open a JSON file?
Open it in any text editor — Notepad, TextEdit, or VS Code — or drag it into a browser window to view it. For a large or minified file, paste it into a JSON formatter first so it is re-indented into a readable structure before you try to read it.
Is JSON a programming language?
No. JSON is a data format, not a language: it has no variables, loops, or functions. It describes data only. Programs in JavaScript, Python, PHP, and most other languages can read and write JSON, which is why the same file works everywhere. MDN's JSON object documentation explains how JavaScript parses and generates it.
What is the difference between JSON and JSONL?
A JSON file is a single document — one object or array, wrapped in matching brackets. A JSONL file is many JSON objects stacked one per line, with no outer wrapper. JSONL suits logs and streaming data; JSON suits configs, API responses, and anything you want to read as one document.
Can I edit a JSON file in Notepad?
Yes, but be careful. Notepad will open and save a .json file without complaint, and it will not warn you if you break the syntax. For anything beyond a one-word change, use VS Code or a formatter tool that checks the syntax as you type, so a missing comma does not silently break the file.
What is the best JSON viewer?
The best JSON viewer is usually the one you already have. A browser's built-in viewer is fine for a quick look, VS Code is best for regular work because it highlights syntax and folds sections, and a free online formatter is best when the file arrives minified on a single line. Pick by how often you read JSON, not by feature lists.