How to Open a JSON File: Every Method, on Every Device (and How to Fix It When It Looks Wrong)

CodexFuse Team · 2026-10-26T23:57:03.717Z · 10 min read

A JSON file is plain text. Here is how to open one on Windows, Mac, Linux, in a browser, or on a phone — and how to fix it when it opens as one unreadable line.

A JSON file is a plain-text file that stores structured data — settings, app data, API responses, data exports — in a format both people and programs can read. To open one, right-click it and choose a text editor: Notepad on Windows or TextEdit on a Mac will show you the raw text, and a code editor like VS Code will show it color-coded and easy to follow.

If you only need a quick look, drag the file into a JSON formatter in your browser and it will lay the data out as a neat, collapsible tree. This guide covers how to open a JSON file on every device, how to read what is inside it, and how to fix the two problems that make JSON files look broken: the one-line minified blob and the file that will not open at all.

JSON stands for JavaScript Object Notation. Douglas Crockford created it in 2001 as a lightweight, language-independent way to exchange data, and it is now used in almost every programming language (Guvi). A file that ends in .json is simply text — which is why you do not need special software to open it.

What you do need is the right tool for the job: a quick glance needs a different app than a 50 MB export you want to search. If the file you were handed is XML rather than JSON, the sibling guide on how to open an XML file covers the same open, format, and fix workflow for that format.

How do I open a JSON file?

Right-click the file, choose “Open with,” and pick a text editor. On Windows that is Notepad for plain text or VS Code for a color-coded view; on a Mac it is TextEdit or VS Code (Guvi). These four steps work for any .json file, whether it came from an app, an API, or a data export.

  1. Right-click the .json file.
  2. Choose “Open with” on Windows or “Open With” on a Mac.
  3. Pick Notepad or TextEdit to see the raw text, or VS Code to see it with syntax highlighting.
  4. If the file opens as one long line, paste it into a JSON formatter — the formatting fix is covered below.

If you do not want to install anything, drag the file into your browser instead: most browsers will display it, and a browser-based JSON viewer will format it as a tree you can fold and unfold. The online route comes with one hard rule, covered in its own section below: never paste a file that holds passwords, API keys, or personal records into any online tool (JSONLint).

Which method should you use to open a JSON file?

Pick by what you need to do, not by habit. The same file can look like plain text in one app and a structured, color-coded view in another (Guvi), so the method decides how much work the reading takes.

GoalBest methodWhat you get
Take one quick lookNotepad (Windows) / TextEdit (Mac)Raw text, no setup
Read and edit regularlyVS CodeSyntax highlighting, folding, error detection
Check if the file is validJSON validatorThe exact line and column of any error
Explore nested dataJSON tree viewerCollapsible branches you can search
Turn a list into rowsJSON-to-table viewSortable columns
Work from a terminaljq, Python, or PowerShellFormatting and queries without opening an app
Open a very large fileStreaming command-line toolNo frozen editor

The table above follows JSONLint’s own fastest-ways guide, which sorts the same choice by goal: small file, validate, nested data, array as rows, terminal, or very large file. The rest of this guide walks through each row in turn.

How to open a JSON file on Windows

Right-click the file, choose “Open with,” and select Notepad or Visual Studio Code. Notepad shows the JSON as plain text; VS Code shows it with colored syntax, which makes the structure far easier to follow (Guvi).

To make your choice stick, right-click the file, choose “Open with,” then “Choose another app,” pick your editor, and turn on “Always use this app” (JSONLint). After that, double-clicking any .json file opens it in the editor you picked.

PowerShell users can pretty-print a file without opening an editor at all. This command reads the file, parses it, and prints it formatted (JSONLint):

Get-Content .\data.json -Raw | ConvertFrom-Json | ConvertTo-Json -Depth 100

Because ConvertFrom-Json actually parses the file, the command also reveals invalid syntax instead of silently showing broken text (JSONLint).

How to open a JSON file on Mac

Control-click the file, choose “Open With,” and pick TextEdit or Visual Studio Code. TextEdit shows plain text; VS Code gives you the color-coded view (JSONLint). If you use TextEdit, make sure the document is treated as plain text rather than rich text, or the file can pick up formatting it should not have (JSONLint).

The fastest Mac-only trick needs no app at all: select the file in Finder and press Space. Quick Look shows a preview of the contents immediately (Convertico). For a tree view, drop the file onto a JSON viewer page in Safari or Chrome instead.

From Terminal, Python can validate and format the file in one step (JSONLint):

python3 -m json.tool data.json

Or use jq if it is installed:

jq . data.json

How to open a JSON file on Linux

Most desktop editors and code editors on Linux open JSON directly. From a terminal, the same three commands cover viewing, querying, and validating (JSONLint):

less data.json
jq . data.json
python3 -m json.tool data.json

Use less for viewing, jq for querying and formatting, and python3 -m json.tool for a dependency-free validation check when Python is available (JSONLint).

How to open a JSON file online

Drag the .json file onto a JSON viewer page, or click to browse for it, and it opens at once as a collapsible tree — you can switch to highlighted code or a table view, and nothing needs installing (Convertico). This is the short answer to how to view JSON file contents on any device: drop the file on a viewer page, with no app to set up first. Most viewers also validate the file as it opens, pointing to the exact line and column of any error (Convertico).

The privacy rule comes first. JSONLint puts it plainly: “Do not paste files containing passwords, API keys, personal records, or other sensitive data into any online tool.” Config files and data exports often hold exactly those things, so format them locally first — with VS Code, jq, or python3 -m json.tool — and keep the online tools for files you would not mind a stranger reading.

There is a safer middle ground: some viewers read the file in your browser and never send it to a server. Convertico’s viewer, for example, reads and shows the JSON in your own browser, “so it is safe for API responses, tokens, config files and customer data.” When you use any online tool, check that it says the file stays on your device before you drop a sensitive file in.

You can also open a JSON file in the browser itself: drag it into a browser window or use File → Open. Browser behavior varies — some display raw text, some format the JSON, and some download the file, depending on the response headers (JSONLint). A Chrome extension such as JSON Formatter turns raw JSON into a clean, readable tree whenever you open a .json file or API response directly in the browser (Guvi).

How to open a JSON file on iPhone and Android

Open a JSON viewer page in Safari or Chrome, tap browse, and pick the file in the Files app on iPhone or in Downloads on Android — it opens right there, with nothing to install (Convertico). A JSON attachment from Mail or Messages can be saved to Files first, then opened the same way (Convertico).

A text-editor or code-viewer app, a browser, or an online validator can all display JSON on a phone (JSONLint). The same privacy rule applies: avoid uploading sensitive files from a phone, where it is harder to check what an app does with them.

How to read a JSON file once it is open

A JSON file holds one value — usually an object in { } with named keys, or an array in [ ] with a list of items. Values can be text in double quotes, numbers, true, false, null, or more objects and arrays nested inside (Convertico). The format is defined by RFC 8259 and ECMA-404 (Convertico).

Here is a small settings file, the kind an app might save, as it appears when opened:

{
  "app": "notes",
  "theme": "dark",
  "autosave": true,
  "notes": [
    { "id": 1, "title": "Groceries" },
    { "id": 2, "title": "Call the plumber" }
  ]
}

Read it from the outside in. The outer { } is one object; “app”, “theme”, and “autosave” are keys with a text value, a text value, and a true/false value.

“notes” is an array — a list in [ ] — and each item in it is another object with its own “id” and “title”. A JSON file viewer shows this same structure as branches you can fold and unfold, which is why it is the easiest way to read a deeply nested file.

TypeLooks likeExample
Text (string)Double quotes"dark"
NumberNo quotes42 or 3.14
True / falseLowercasetrue
NullLowercasenull
Object{ }{"id": 1}
Array[ ]["a", "b"]

Two rules explain most reading mistakes. First, JSON keys and text values must be in double quotes — single quotes are not valid JSON.

Second, a file with two objects stacked on top of each other is not one JSON document at all; the validator will reject it. That stacked format has its own name — JSON Lines, one value per line — and it opens in a JSON Lines viewer, not a strict JSON parser (Convertico; JSONLint).

Why does my JSON file look messy?

It is almost certainly minified: all the spacing was stripped out to make the file smaller, so the whole document sits on one line. It is still valid JSON — just difficult to inspect (JSONLint). Guvi’s FAQ puts it the same way: a messy-looking file is “likely minified (no spacing)” and a formatter makes it readable.

Here is the same settings file from the previous section after minifying — one line, same data:

{"app":"notes","theme":"dark","autosave":true,"notes":[{"id":1,"title":"Groceries"},{"id":2,"title":"Call the plumber"}]}

Fix it by formatting the file. That is the whole answer to how to format JSON: take the one-line file and give it indentation again. Paste it into a JSON formatter, or run one of these commands (JSONLint):

jq . data.json > formatted.json
python3 -m json.tool data.json formatted.json

Keep the original until you have verified the formatted output (JSONLint) — formatting should never change the data, only the spacing.

The other common “messy” cause is encoding. If the file shows strange characters, reopen it as UTF-8: a byte-order mark (BOM) or a different source encoding can cause parse errors (JSONLint). Guvi’s best-practice list says the same: use UTF-8 encoding so you get readable text, not raw bytes.

How to fix a JSON file that will not open

Start with the validator: it points to the exact line and column of the problem, and most viewers offer an auto-fix for the common mistakes (Convertico). The mistakes below cause almost every “not valid JSON” error (Convertico; JSONLint):

MistakeBrokenValid
Trailing comma[1, 2, 3,][1, 2, 3]
Single quotes{'a': 'b'}{"a": "b"}
Unquoted keys{name: "x"}{"name": "x"}
Comment in the file// noteRemove it — JSON has no comments
Missing comma{"a": 1 "b": 2}{"a": 1, "b": 2}
NaN or Infinity{"x": NaN}{"x": null}
Python valuesTrue, Nonetrue, null
Single backslash"C:\data""C:\\data"
Missing bracket[{"a": 1}[{"a": 1}]

Three traps deserve their own lines. A hidden byte-order mark at the start trips up many parsers (Convertico).

A file saved from Notepad can end up named data.json.txt — change the save type to “All Files” when you save, or the .json extension is not really there (MakeTechEasier). And a file with no .json extension at all can still be valid JSON: an extension is a convention, not proof of content, and a valid JSON document can be a string, number, boolean, or null — not only an object or array (JSONLint).

If the viewer says the file is binary, it is not text at all — often a ZIP, image, or database file wearing a .json name — and it needs a different tool entirely (Convertico).

How to edit a JSON file safely

Open it in a code editor, not a word processor, and validate it after every change. JSONLint’s edit rules are short enough to keep on a sticky note: keep keys and string values in double quotes; remove trailing commas and comments unless the format is explicitly JSONC; preserve UTF-8 encoding; validate after every manual change; and use version control or a backup for configuration files.

One more caution: do not reorder keys if another system incorrectly depends on their textual order (JSONLint). Key order should not matter, but some tools read the file as text rather than data, and reordering can break them.

What to do next with the file

Once you can read the file, the next step depends on where the data is going. If it is a list of records, a JSON-to-CSV converter turns it into a spreadsheet: any list of objects becomes rows, and nested objects are flattened into columns like address.city (Convertico).

The step-by-step version is covered in the guide to convert JSON to CSV. If the data needs to move into an XML-based system, a JSON-to-XML converter converts the whole document while keeping the nesting (Convertico).

And if the file you were handed turns out to be XML rather than JSON, the guide on open an XML file covers the same open, format, and fix workflow for that format.

Sources

Frequently asked questions

Can I open a JSON file with Notepad?

Yes — right-click the file, choose “Open with,” and select Notepad, and it will show as plain text (Guvi). For anything more than a quick look, a code editor or formatter is easier to read.

What program opens JSON files by default?

Most systems do not have a default program for .json files. You choose how to open it — usually a text editor or a browser (Guvi). Set your editor as the default once, and double-clicking will open every JSON file in it.

Can I open a JSON file in Excel?

Yes, but you need to import it through Excel’s Get Data or Power Query feature — it will not open directly like a text file (Guvi). For a quick conversion, a JSON-to-CSV tool turns the list into rows first.

Why does my JSON file look messy when I open it?

It is likely minified, with all spacing removed. Paste it into a JSON formatter or run jq or python3 -m json.tool on it, and it will come back as readable, indented text (Guvi; JSONLint).

Is it safe to open a JSON file in an online tool?

Only if the file holds nothing sensitive. Never paste files containing passwords, API keys, or personal records into any online tool (JSONLint). Format sensitive files locally — VS Code, jq, or python3 -m json.tool — or use a viewer that reads the file in your browser and never uploads it.