How to open .JSON files on Linux

To open .JSON files on Linux, open the .json file in a text editor (any plain-text editor works) or a code editor that supports JSON features.

Step-by-step instructions

  1. Open the .json file in a text editor (any plain-text editor works) or a code editor that supports JSON features.
  2. To validate and pretty-print from the terminal (if installed), run: jq . file.json
  3. If the desktop doesn’t recognize the file type, it may rely on shared-mime-info mappings; still, any text editor can open it as plain text.

Common issues

“Unexpected token” / JSON parse error

JSON syntax is strict: missing quotes, trailing commas, or invalid characters will break parsing.

  1. Check for trailing commas and ensure all property names and string values use double quotes.
  2. Validate with a JSON-aware editor (for example, VS Code JSON features) or a validator tool.
  3. If you control the source, regenerate/export the JSON again to avoid manual syntax mistakes.

File opens but is one long line (minified JSON)

Many systems store JSON without whitespace to reduce size, making it difficult to read manually.

  1. Use your editor’s JSON formatter/pretty-print feature (VS Code supports JSON editing and formatting for .json files).
  2. On Linux, pretty-print in the terminal with: jq . file.json (if jq is installed).

App says the file type is unknown or opens in the wrong program

File associations vary by system and can be changed; MIME/type recognition can also differ across environments.

  1. Use “Open with” to choose a text/code editor and set it as the default for .json if desired.
  2. If the file was renamed, confirm it truly contains JSON text (it should start with { or [ in most cases).

Encoding or character issues (garbled text)

JSON is text, but problems can occur if a tool saves it with an unexpected encoding or adds a byte order mark (BOM) that some parsers reject.

  1. Re-save the file as plain text using UTF-8 in a code editor.
  2. If a parser fails, try removing any leading invisible characters by copying the content into a new file and saving as UTF-8.

Security note

Treat JSON from untrusted sources as untrusted input: validate the structure (and ideally against a schema) before using it in production systems.

Back to .JSON extension page