.json

What is a .json file?

JavaScript Object Notation · Code and data · Douglas Crockford · 2001

JSON is the most common format for exchanging structured data between programs and web APIs. It is plain text made of key-value pairs and lists, easy for both humans and machines to read, which is why it powers most modern web services.

Category
Code and data
Type
Plain text
Is a .json file safe to open? Safe. JSON is pure data and does not execute. Only the program that reads it decides what to do with the values.

What is a .json file used for?

JSON represents data as objects (key-value pairs in braces) and arrays (lists in brackets). It is concise, unambiguous and maps neatly onto the data structures of nearly every programming language.

It replaced XML for most web APIs because it is lighter and easier to read. Config files, app settings and API responses are frequently JSON.

Being plain text, a JSON file opens in any editor. Formatting it with indentation, known as pretty-printing, makes large files far easier to scan.

What opens a .json file?

The .json format opens in the following apps, grouped by operating system. If one app does not work, try another from the same list.

Windows

  • Notepad++
  • VS Code
  • any text editor

macOS

  • VS Code
  • TextEdit
  • any editor

Linux

  • VS Code
  • nano
  • any editor

Web

  • Browsers show raw JSON; dev tools format it

Open a .json file step by step

  1. Confirm the file really is a .json. Drop it into the WhatFileType identifier, which reads its signature in your browser without uploading anything.
  2. On Windows, open it with Notepad++ or VS Code.
  3. On Mac, use VS Code or TextEdit.
  4. On Linux, try VS Code or nano.
  5. Still stuck? Convert the .json to CSV, which opens more widely.

Why can't I open my .json file?

Almost always because no installed app understands JSON. Install one of the apps above, or convert the file to a format your existing software already reads. If double-clicking opens the wrong program instead of nothing at all, the file association is set to the wrong app rather than the file being broken.

The other possibility is that the file is not really a .json at all. Drop it into the file identifier to check it by its bytes instead of its name. Nothing is uploaded.

How to convert a .json file

You can convert a .json file to CSV, XML, YAML.

jq converts JSON to CSV in a single pipeline and Python's json plus csv modules do it in five lines. Flattening to CSV forces a decision about nested objects and arrays, which is where the data loss happens.

What is the .json file signature (magic bytes)?

A .json file may start with the hex bytes 7B, which read as { in ASCII. Those bytes are a hint rather than a guarantee, so JSON cannot be identified by its header alone.

These are the documented signatures for JSON.

Documented magic-byte signatures for the .json format
Hex signatureOffsetASCIINote
7B0{'{' object (usually)
5B0['[' array

See the full magic-numbers reference for every format.

Frequently asked questions

What is a .json file?

JSON is the most common format for exchanging structured data between programs and web APIs. It is plain text made of key-value pairs and lists, easy for both humans and machines to read, which is why it powers most modern web services.

How do I open a JSON file?

Any text editor works. For a formatted, colour-coded view, open it in VS Code or drop it into your browser's developer tools.

Why does my JSON file say invalid?

JSON is strict: keys need double quotes, no trailing commas, and no comments. A validator will point to the exact line that breaks the rules.

Comparisons

Related formats

Sources

Details on this page were checked against authoritative references. How sources are ranked and what is deliberately left out is set out in the methodology.