.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.

How to open 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. For a step-by-step walkthrough, see how to open a .json file.

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

How to convert a .json file

You can convert a .json file to CSV, XML, YAML using a conversion tool or the export menu of an app that opens it.

.json file signature (magic bytes)

Programs recognise a .json file by the bytes at the start of the file, not by its name. These are the signatures for JSON.

Hex signatureOffsetNote
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: