Skip to content
JSON Viewer

Guide

JSON vs JSONC vs JSON5: What Is the Difference?

JSON is the strict data format defined by RFC 8259. JSONC and JSON5 are relaxed supersets that make files easier for people to write. Every valid JSON document is also valid JSONC and JSON5, but not the other way round.

At a glance

Feature JSON JSONC JSON5
Comments (//, /* */) No Yes Yes
Trailing commas No Usually Yes
Single-quoted strings No No Yes
Unquoted keys No No Yes
Hex numbers, Infinity, NaN No No Yes
Multi-line strings No No Yes
Native parser in every language Yes No No

JSON: for data exchange

Use strict JSON for API requests and responses, data files, and anything another program will read. Every language has a fast, built-in parser, and there is only one way to interpret a document.

JSONC: JSON with comments

JSONC adds comments and, in most tools, trailing commas. It is used for configuration files people edit by hand, such as VS Code’s settings.json and TypeScript’s tsconfig.json.

{
  // Use two-space indentation
  "editor.tabSize": 2,
}

JSON5: JSON for humans

JSON5 goes further and borrows more of JavaScript’s syntax: single quotes, unquoted keys, hexadecimal numbers and multi-line strings. It needs a dedicated parser library.

{
  name: 'getjsonviewer',
  maxSize: 0x10000,
}

Converting JSONC or JSON5 to strict JSON

If a tool rejects your file with a syntax error, it probably expects strict JSON. Paste the file into the JSON repair tool and press Fix. Comments are removed, quotes are normalised and trailing commas dropped, leaving valid JSON you can format or validate.