Key facts
- Defined by RFC 8259 and ECMA-404; must be encoded as UTF-8 when exchanged between systems.
- MIME type is application/json.
- Keys and strings need double quotes; comments, trailing commas, single quotes, NaN and undefined are not allowed.
- JSON Lines (.jsonl) puts one JSON value per line and is common for logs and large exports.
- Variants such as JSONC (VS Code settings) and JSON5 allow comments but are not valid strict JSON.
How to open a .json file
Open it in VS Code or Notepad++, or drag it into Firefox or Edge, which show a collapsible viewer. In PowerShell, Get-Content file.json | ConvertFrom-Json parses it.
Open it in any code editor or a browser, or run python3 -m json.tool file.json in Terminal to validate and pretty-print it.
Run jq . file.json to pretty-print and validate, or python3 -m json.tool file.json if jq is not installed.
Common problems and fixes
- "Unexpected token" or "Expecting property name enclosed in double quotes"
- The file uses single quotes, unquoted keys or comments, which strict JSON forbids. Replace single quotes with double quotes and remove comments.
- Trailing comma error near } or ]
- A comma after the last item in an object or array is invalid JSON. Delete that comma; the parser's line and column number point to it.
- "Unexpected end of JSON input"
- The file or API response was cut off, or is empty. Check for missing closing brackets and confirm the full response arrived.
- "Unexpected token < in JSON at position 0"
- The server returned an HTML page (often an error page or login redirect) instead of JSON. Open the URL directly to see the real response and fix the endpoint or authentication.
- Invisible characters or a BOM break parsing
- Some editors save a UTF-8 byte-order mark or copy smart quotes. Re-save as UTF-8 without BOM and replace curly quotes with straight ones.
Often converted to or from: CSV, XML, YAML, PHP array, JSON Lines