GameParticles
Developer

What Is a JSON File? Data Types, Example, How to Open

What is a JSON file? A plain text format for structured data built from objects and arrays. See the six data types, a real example and how to open one.

Updated

A JSON file is a plain text file that stores structured data as nested objects and arrays, using a syntax borrowed from JavaScript. JSON stands for JavaScript Object Notation; files use the .json extension and the media type application/json. It is the default format for web APIs and a great many configuration files because it is easy for people to read and trivial for programs to parse.

What JSON looks like

Here is a complete, valid JSON document:

{"id": 42, "name": "Ada Lovelace", "active": true, "manager": null, "tags": ["admin", "beta"], "address": {"city": "London", "postcode": "W1"}}

Read it left to right. The outer curly braces make an object, which is a set of key and value pairs. "id" is a key and 42 is its value. "tags" holds an array, written with square brackets. "address" holds another object, nested inside the first. Nesting can go as deep as you need, which is what lets JSON describe things a flat table cannot.

Spaces and line breaks between tokens do not matter. The same data can be written on one line, as above, or spread over many indented lines. Servers usually send the compact form to save bytes; people prefer the indented form.

The six data types

Every JSON value is one of exactly six types:

TypeExampleNotes
String"hello"Always double quotes. Special characters use backslash escapes such as \n and \"
Number42, -3.14, 1.5e10No quotes. No leading zeros, no hex, no NaN or Infinity
Booleantrue, falseLowercase only
NullnullLowercase. Means "no value"
Object{"a": 1}Unordered pairs. Keys must be double-quoted strings
Array[1, "two", null]Ordered list. Items can be of mixed types

That is the whole type system. There is no date type, so dates travel as strings, usually in ISO 8601 form such as "2026-11-17T09:30:00Z", or as numbers holding a Unix timestamp. There is no separate integer type either. JSON itself puts no limit on number size, but many parsers read numbers as 64-bit floats, which hold integers exactly only up to 9,007,199,254,740,991. That is why APIs often send large IDs as strings.

A JSON document is a single value. Most often the top level is an object or an array, but a lone string or number is valid too.

The syntax rules that trip people up

JSON looks like a JavaScript object literal, but it is stricter:

  • Keys must be in double quotes. {name: "Ada"} is JavaScript, not JSON.
  • Strings use double quotes only. Single quotes are invalid.
  • No trailing commas. [1, 2, 3,] fails.
  • No comments of any kind.
  • No undefined, no functions, no dates.
  • Line breaks inside a string must be written as \n, not as a real new line.

Break any of these and a parser rejects the entire file, not just the bad line. The separate guide on how to format and validate JSON walks through the error messages and how to fix each one. For the backslash sequences allowed inside strings, see escape characters explained.

Where JSON came from

Douglas Crockford popularized the format in the early 2000s as a lightweight way for browsers and servers to exchange data without XML. It is now specified by two matching documents: RFC 8259, published in 2017, and the ECMA-404 standard. RFC 8259 also requires UTF-8 encoding when JSON is exchanged between systems, so a JSON file can hold text in any language, emoji included.

Although the syntax comes from JavaScript, JSON is language independent. Python, Java, Go, C#, PHP, Ruby, Rust and Swift all ship with or have standard libraries for reading and writing it.

How to open a JSON file

A JSON file is text, so you never need special software to see what is inside:

  1. Text editor. Notepad on Windows and TextEdit on macOS will open any .json file. A code editor such as VS Code adds color and can fold nested sections; its Format Document command indents the file.
  2. Web browser. Drag the file into Firefox and it displays a collapsible tree with a filter box. Chrome and Edge show the raw text.
  3. Online formatter. If the file is one enormous line, paste it into the JSON Formatter. It indents the structure with two or four spaces, or reports the parser's error message if the content is not valid JSON.
  4. Command line. python3 -m json.tool data.json pretty-prints a file with nothing extra installed. If you have jq, jq . data.json does the same with color, and jq .address.city data.json pulls out a single value.

In code, reading JSON is a one-liner: JSON.parse(text) in JavaScript, json.load(file) in Python. Writing it is JSON.stringify(value, null, 2) and json.dump(value, file, indent=2).

If double-clicking a .json file does nothing useful, that is because your system has no default app for the extension. Right-click it, choose Open with, and pick a text editor.

How to read a large JSON file

Start from the outside. Check whether the top level is { (one object) or [ (a list of things). If it is an array, look at the first element only; the rest almost always have the same shape. Then note the keys at each level and ignore the values until you find the part you need.

Indentation does most of the work here, which is why formatting first is worth the few seconds. Once you know the path to a value, for example orders[0].items[2].price, you can pull it out in code or with jq.

JSON describes data, not behavior. A JSON file cannot run code, so opening one in a text editor or a formatter is safe. The risk only appears when a program trusts the values inside without checking them.

JSON and other formats

JSON is one of several text formats for structured data, and conversions between them are common:

  • Tabular data such as a list of records fits CSV, which spreadsheets open directly. The JSON to CSV Converter turns an array of objects into rows and columns. See what a CSV file is for that format's rules.
  • Configuration that people edit by hand is often written in YAML, which allows comments. YAML vs JSON compares the two.
  • Older enterprise systems and document formats use XML. JSON vs XML shows the same data in both.

JSON's niche is the middle ground: structured enough for nested data, simple enough that every language reads it the same way.

Try it

Paste the contents of any .json file into the JSON Formatter to see it indented and to confirm it is valid. Switch to Minify to get the compact single-line version for a request body or an environment variable.

Tools in this guide

Frequently asked questions

What is JSON?

JSON (JavaScript Object Notation) is a text format for structured data. It represents values as objects with named keys, ordered arrays, strings, numbers, booleans and null. It is language independent and is the most common format for web APIs and configuration files.

How do I open a JSON file?

Any text editor opens it, because a JSON file is plain text: Notepad, TextEdit or VS Code all work. Firefox shows a collapsible tree when you drag a .json file into a tab. For a file that is all on one line, paste it into a JSON formatter to indent it.

What is JSON used for?

Mostly for sending data between programs. Web and mobile apps exchange JSON with servers through APIs, tools such as npm and VS Code store settings in JSON files, and databases like PostgreSQL and MongoDB store JSON-style documents directly.

Can a JSON file have comments?

No. Standard JSON has no comment syntax, and a parser will reject // or /* */. Some tools accept relaxed variants such as JSONC or JSON5 for their own config files, but those are separate formats. If you need notes, add a normal key such as "_comment".

More developer guides

JSON Formatter
Developer · Format, validate and minify JSON with syntax highlighting.
↵
Base64 Encode / Decode
Developer · Encode text to Base64 or decode Base64 back to plain text.
↵
URL Encoder / Decoder
Developer · Encode or decode URL components and query strings.
↵
Hash Generator
Developer · Generate MD5, SHA-1, SHA-256 and SHA-512 hashes.
↵
UUID Generator
Developer · Generate UUIDs v4 (random) in bulk with one click.
↵
Regex Tester
Developer · Test regular expressions against text with live match highlighting.
↵
Word Counter
Text · Count words, characters, sentences, paragraphs and reading time.
↵
Case Converter
Text · Convert text between UPPER, lower, Title, camelCase, snake_case and more.
↵
List Sorter
Text · Sort, reverse, deduplicate and shuffle lists of text.
↵
Markdown Preview
Text · Write Markdown and see a live rendered preview side by side.
↵
Percentage Calculator
Numbers · Calculate percentages, increases, decreases and what % one number is of another.
↵
Color Converter
Colors · Convert colors between HEX, RGB, HSL and HSV instantly.
↵
Snake
Arcade · Eat food, grow longer, don't hit the walls. A timeless classic.
↵
2048
Puzzle · Slide tiles and combine them to reach the legendary 2048 tile.
↵
Word Grid
Puzzle · Guess the hidden five letter word in six tries using color clues.
↵
Sudoku
Puzzle · Fill the 9x9 grid with logic. Four difficulties from easy to expert.
↵
Minesweeper
Strategy · Use number clues to clear the minefield. Classic logic, three levels.
↵
Breakout
Arcade · Smash every brick with paddle and ball. Power-ups, combos, endless levels.
↵
Typing Practice
Casual · Build your WPM and accuracy with timed drills from 30 seconds to 5 minutes. Find your weak keys.
↵
TypeRunner
Arcade · Multiplayer typing race. Race friends by link, beat computer runners, or chase your own ghost.
↵
Typing Blocks
Arcade · Type each word before its wooden block lands. Miss, and the pile climbs toward the line.
↵
Bubble Shooter
Arcade · Aim, bank shots off the walls, and pop groups of three or more bubbles.
↵
Road Rush
Arcade · Race seven rivals through traffic and punch your way to the front.
↵