Free online JSON formatter, validator, and developer tools.
Strict JSON is deliberately minimal — no comments, no trailing commas, quoted keys only. That minimalism makes it an excellent wire format, but a frustrating one to hand-edit. JSON5 is a community-driven superset of JSON that relaxes exactly those restrictions, aimed squarely at files humans write and maintain by hand: configuration files, build manifests, and data humans read.
JSON5 is a strict superset — every valid JSON document is also valid JSON5. It adds:
// single-line and /* */ block commentsInfinity, NaN, and a leading + signHere is the same configuration written first as strict JSON, then as JSON5:
// Strict JSON — no comments allowed, this is illustrative only
{
"name": "my-app",
"port": 8080,
"features": ["auth", "logging"],
"debug": false
}
// JSON5 — comments and trailing commas are fine
{
// Server configuration
name: 'my-app',
port: 8080,
features: [
'auth',
'logging', // trailing comma is OK
],
debug: false, // also OK here
}
The JSON5 version is shorter to type, easier to diff in version control (trailing commas mean adding a line doesn't touch the line above it), and self-documenting via comments — none of which strict JSON supports.
JSON5 rarely appears on the wire between client and server — strict JSON remains the standard for APIs. Its real home is configuration:
.babelrc as JSON5 as well as strict JSONsettings.json and tasks.json use a JSON-with-comments variant in the same spiritThe pattern is consistent: any file a human is expected to open, read, and edit by hand is a good JSON5 candidate. Any file exchanged purely between programs should stay as strict JSON, because strict JSON has near-universal, zero-ambiguity parser support.
Node's built-in JSON.parse only accepts strict JSON — comments and trailing commas throw a SyntaxError. Use the json5 npm package instead:
npm install json5
const JSON5 = require('json5');
const fs = require('fs');
const raw = fs.readFileSync('config.json5', 'utf8');
const config = JSON5.parse(raw);
console.log(config.name); // 'my-app'
// JSON5 can also stringify back out, optionally without quoting keys
const text = JSON5.stringify(config, null, 2);
The API deliberately mirrors the built-in JSON object (JSON5.parse, JSON5.stringify), so swapping strict JSON parsing for JSON5 parsing in an existing codebase is usually a one-line change.
Python's standard library json module is strict as well. The json5 PyPI package fills the same gap:
pip install json5
import json5
with open('config.json5') as f:
config = json5.load(f)
print(config['name']) # 'my-app'
An alternative worth knowing about: Python's own json module already tolerates some non-strict input if you pass parse_constant, but it does not support comments or trailing commas — for those you still need the dedicated json5 package.
JSON5 isn't the only human-friendly config format. Here's how the three most common options compare:
Cargo.toml) and Python (pyproject.toml) tooling, explicit and unambiguous, but more verbose for deeply nested dataIf your project's config already round-trips through JSON elsewhere (build tools, IDE integrations, JSON Schema validation), JSON5 is usually the path of least resistance since your existing JSON tooling largely still applies. If deep nesting and human authorship are the priority, YAML tends to win. For more on the JSON-vs-YAML tradeoff specifically, see our JSON vs YAML comparison.
JSON5's flexibility comes with a few sharp edges:
"content-type" (with a hyphen) still needs quotesNaN and Infinity aren't valid JSON — if you round-trip a JSON5 file that uses them through a strict JSON parser elsewhere in your pipeline, it will failJSON5 keeps JSON's simple, JavaScript-object-literal-like structure while removing the friction of hand-editing: comments explain intent, trailing commas keep diffs clean, and unquoted keys reduce visual noise. It's the right choice for configuration files that developers read and edit directly — Babel configs, build manifests, editor settings — but it should stay out of your network API responses, where strict JSON remains the universal, unambiguous standard.
Need to convert a JSON5 config down to strict JSON, or just validate the underlying structure? Paste it into our free JSON Formatter after stripping comments and trailing commas.