Developer Tools

What Is a JSON File and How Do You Open It?

JSON is a plain-text format for structured data. It is readable enough for people to inspect and strict enough for programs to parse consistently.

JSON is a plain-text format for structured data. It is readable enough for people to inspect and strict enough for programs to parse consistently.

What JSON means

JSON stands for JavaScript Object Notation. Despite the name, many programming languages use it for APIs, configuration, exports, and application data. A .json file contains text organized as objects, arrays, strings, numbers, booleans, or null.

A simple JSON file example

{
  "name": "ToolZone",
  "active": true,
  "tools": ["formatter", "viewer"],
  "count": 2
}

Property names and string values use double quotes. Commas separate members, but the final member in an object or array does not have a trailing comma in standard JSON.

How to open a JSON file

Because JSON is text, you can open it in a text editor, code editor, or browser. A large minified file may appear on one long line. Paste a trusted copy into the JSON Formatter to validate it and add indentation, or use the JSON Viewer to explore nested values.

Do not paste credentials, private API responses, tokens, or customer data into an online service. ToolZone's formatter works in the browser, but the device and browser environment still need to be trusted.

Common JSON syntax errors

  • Using single quotes instead of double quotes.
  • Leaving a trailing comma after the final item.
  • Missing a comma, colon, quote, bracket, or brace.
  • Including comments, undefined, or other JavaScript-only values.
  • Placing unescaped line breaks or quotation marks inside a string.

A formatter can identify the approximate parse position, but inspect the surrounding structure because the real mistake may occur just before that point.

JSON versus CSV

CSV is compact for flat rows and columns. JSON handles nested objects, lists, and explicit data types more naturally. Use JSON to CSV only when the structure can be represented as a table without losing important relationships.

Parse JSON in JavaScript

const value = JSON.parse(jsonText);
const formatted = JSON.stringify(value, null, 2);

JSON.parse converts valid JSON text into a JavaScript value. JSON.stringify converts supported JavaScript data into JSON text. Wrap parsing of untrusted or variable input in try...catch, validate the resulting shape, and do not use eval as a JSON parser.

JSON is stricter than a JavaScript object literal: property names and strings use double quotes, comments and trailing commas are not valid, and functions, undefined, and several other JavaScript values are not represented directly. Use the JSON Parser and Formatter to test syntax locally.