In this article
What Is JSON5?
JSON5 is a superset of JSON that adds features inspired by ECMAScript 5.1 syntax. It was created to make JSON more human-friendly for configuration files and other cases where people write and read JSON by hand. Every valid JSON document is also valid JSON5, but JSON5 adds comments, trailing commas, unquoted keys, and other conveniences.
The JSON5 specification was finalized in 2018 and is widely adopted in JavaScript tooling. Build tools like Babel, Next.js, and Webpack accept JSON5 configuration files. Converting JSON5 to standard JSON is necessary when interoperating with systems that only understand strict JSON, such as APIs, databases, and most programming languages.
JSON5 Features Explained
JSON5 adds several syntax extensions that make configuration files easier to write and maintain.
- Comments — both single-line (//) and multi-line (/* */) comments are allowed, making config files self-documenting
- Trailing commas — arrays and objects can have a comma after the last item, reducing diff noise when adding or removing entries
- Unquoted keys — object keys that are valid ECMAScript identifiers do not need quotes, making configs more concise
- Hexadecimal numbers — numeric values can be written as 0xFF, useful for color codes and bitmasks in configuration
- Multi-line strings — string values can span multiple lines using backslash continuation, helpful for long descriptions or paths
- Special numeric values — Infinity, -Infinity, and NaN are valid numeric literals in JSON5
Try it free — no signup required
Convert JSON5 to JSON →Where JSON5 Is Used
JSON5 is primarily used in JavaScript ecosystem tooling where configuration files are written and maintained by developers.
- Babel — .babelrc and babel.config.json5 files support JSON5 syntax for build configuration with comments
- TypeScript — tsconfig.json supports JSON5 features like comments and trailing commas (technically JSONC)
- Chrome DevTools — network throttling profiles and other settings use JSON5 format
- Next.js — configuration files accept JSON5 for developer-friendly setup with inline documentation
Frequently Asked Questions
Can browsers parse JSON5 natively?
No. Browsers only support standard JSON via JSON.parse(). To parse JSON5 in a browser or Node.js application, you need the json5 npm package. Build tools that support JSON5 handle the parsing internally during their build step.
What is the difference between JSON5 and JSONC?
JSONC (JSON with Comments) only adds comment support to JSON. JSON5 is a broader superset that adds comments, trailing commas, unquoted keys, hex numbers, multi-line strings, and special numeric values. TypeScript's tsconfig.json and VS Code's settings.json use JSONC, while Babel and other tools use full JSON5.
Is JSON5 the same as YAML?
No. JSON5 stays close to JSON syntax with small ergonomic additions. YAML is a completely different format with whitespace-based structure, anchors, and many more features. JSON5 is easier to convert to JSON because it is a strict superset. YAML-to-JSON conversion can be lossy because YAML supports data types that JSON does not.