What opens a .json file?

Dark navy cover card with the title 'What opens a .json file?' in white and a green accent bar

Any text editor can open a JSON file, because a .json file is plain text: Notepad on Windows, TextEdit on a Mac, or a code editor like VS Code. To read a large file comfortably, open it in Firefox or a JSON viewer that shows a collapsible tree. To analyze the data in rows and columns, import it into Excel with Power Query.

What a .json file actually is

A .json file is a plain-text document that holds data written in the JSON format. The format's standard, RFC 8259, registers .json as the file extension and application/json as the media type, and lists the classic Mac file type code as TEXT. Files exchanged between systems must be UTF-8.

So you don't need special software. The file is just characters like {"name": "Ada", "active": true}. A program only adds indentation, colours, folding and error messages. If you're new to the syntax itself, what the JSON format is covers the rules.

Which program to use, by what you want to do

The right program depends on whether you want to read the file, change it, analyze it or process it in a script. Here's how I choose:

Goal Good choice Why
Take a quick look Any text editor Opens instantly, nothing to install
Read a big or nested file Firefox, or a JSON viewer Collapsible tree and a filter box
Edit and save VS Code or another code editor Folding, formatting, error squiggles
Analyze as a table Excel with Power Query Flattens records into rows
Process in a script jq on the command line Pretty-prints and filters from the terminal

Open it in a text editor

A text editor is the simplest way to open a JSON file, and every computer already has one. On Windows, right-click the file, choose Open with and pick Notepad. On a Mac, choose Open With and then TextEdit.

The catch: a minified API response arrives as one enormous line, and you'll be scrolling sideways. Nor will a text editor tell you when a missing comma breaks the file.

Open it in Firefox

Firefox has a built-in JSON viewer that turns on when you open a JSON file in the browser. Drag the file into a Firefox window. According to the Firefox JSON viewer documentation, the content is parsed and syntax-highlighted, arrays and objects start collapsed with + icons to expand them, and a search box filters the data.

Two tabs at the top switch to the raw text or a pretty-printed version. The viewer also handles .jsonl (JSON Lines) files, showing each line as its own collapsible entry, although pretty-printing isn't offered for those. When you load a URL that returns application/json, the viewer shows the request and response headers too.

Open it in VS Code to edit

VS Code is the program I'd set as the default for .json files, because editing JSON by hand is where mistakes happen. The VS Code JSON documentation lists folding for every object and array, suggestions as you type, and validation against a JSON schema with red squiggles. To re-indent a messy file, run Format Document: Shift+Alt+F on Windows, Shift+Option+F on macOS, Ctrl+Shift+I on Linux.

One detail confuses people. VS Code opens its own settings.json, tasks.json and launch.json in a "JSON with Comments" mode that accepts // comments and trailing commas. Paste one of those files into a strict validator and it fails, even though VS Code reads it fine. That is a different format, explained in JSON vs JSON5 vs JSONC and whether JSON can have comments.

Open it in Excel as a table

Excel opens JSON through Power Query, which turns nested data into rows and columns. The steps from Microsoft's Power Query JSON connector page:

  1. On the Data tab, select Get Data and choose the JSON option.
  2. Pick your file in the file browser and select Open.
  3. The Power Query editor opens and flattens the JSON into a table automatically.
  4. Transform the columns if you need to, then load the result into a sheet.

If Excel says it is unable to connect, Microsoft names three causes: the file isn't really JSON, it's malformed, or it's a JSON Lines file with one object per line. A truncated download is the usual malformed case, the same problem behind Unexpected end of JSON input. For JSON Lines, the same Microsoft page gives a short M script that reads the file line by line with Lines.FromBinary and parses each line with Json.Document.

If you only need a CSV and not a live query, converting JSON to CSV is often quicker.

Open it from the command line with jq

jq is the tool for opening JSON in a terminal and doing something with it. The jq manual describes every jq program as a filter that takes an input and produces an output, and the simplest filter, ., returns its input unchanged. Because jq pretty-prints by default, this is all you need to read a minified file:

jq . data.json

jq '.items[].name' data.json pulls one field out of every item. Faster than scrolling.

Open it in an online JSON viewer

An online JSON viewer is the fastest option when you don't want to install anything: paste the text and get a formatted, collapsible tree. The JSON viewer on this site works that way, with no sign-up. Its tool code processes what you paste with JavaScript in the page and makes no network requests with it.

The limitation of any web-based viewer is trust. You're relying on the page to do what it says, and many sites don't say what happens to pasted data at all. Keep customer records, tokens and credentials in a local editor or jq unless you've checked how the tool handles input.

FAQ

Can Notepad open a JSON file?

Yes. A .json file is plain text, so Notepad, TextEdit or any other text editor opens it. You just won't get indentation, folding or error checking.

How do I open a JSON file in Excel?

Use Data, Get Data and the JSON option, pick the file and select Open. Power Query opens and flattens the JSON into a table you can load into a sheet.

Why won't my JSON file open in Excel?

Microsoft lists three causes: the file isn't really JSON, it's malformed, or it's a JSON Lines file with one object per line. JSON Lines needs a small Power Query script.

Is it safe to open a JSON file?

A JSON file is data, not a program, so opening it in a text editor or browser doesn't run anything. Be careful with what you paste it into: sensitive data belongs in tools that keep it on your machine.

What program should I set as the default for .json files?

A code editor such as VS Code is the most useful default, because it shows the text, folds nested objects and formats the file on demand.

Sources