JSON5 → JSON Converter
Paste JSON5 (with comments, trailing commas, unquoted keys) and convert it to standard JSON.
JSON5 Input
Standard JSON Output
JSON5 vs JSON — The Bottom Line
Use JSON5 for configuration files that humans edit — where comments explaining options and trailing commas reducing diff noise genuinely improve the developer experience. Use standard JSON for everything else: API responses, data storage, machine-generated data, and anything consumed programmatically.
JSON5 is a superset of JSON — every valid JSON document is also valid JSON5. JSON5 adds features from ECMAScript 5 that make it more comfortable for humans to write and read.
Side-by-Side Example
JSON5
json5
// JSON5 — A superset of JSON for human-written config files
{
// Application settings
name: "my-app", // unquoted keys are allowed
version: '1.0.0', // single-quoted strings
server: {
host: "localhost",
port: 8080,
debug: true, // trailing comma in object
},
// Arrays with trailing commas
features: [
"auth",
"logging",
"metrics", // trailing comma in array
],
// Numeric literals
maxInt: 0xFF, // hex number
pi: .5, // leading decimal point
timeout: +Infinity, // special float
// Multi-line string
description: "This is a long description that spans multiple source lines",
}Standard JSON equivalent
json
{
"name": "my-app",
"version": "1.0.0",
"server": {
"host": "localhost",
"port": 8080,
"debug": true
},
"features": [
"auth",
"logging",
"metrics"
],
"maxInt": 255,
"pi": 0.5,
"timeout": null,
"description": "This is a long description that spans multiple source lines"
}What JSON5 Adds Over JSON
| Feature | JSON | JSON5 | Example |
|---|---|---|---|
| Comments | Not supported | // and /* */ | // This is a comment |
| Trailing commas | Not allowed | Allowed | { "a": 1, } and ["x",] |
| Unquoted keys | Must be quoted | Valid identifiers | { name: "value" } |
| Single-quoted strings | Not allowed | Allowed | { name: 'John' } |
| Multiline strings | Escaped \n | Backslash escape | "line1 \ line2" |
| Hex numbers | Not supported | 0x prefix | port: 0x1F90 |
| Leading decimal | 0.5 required | .5 allowed | pi: .5 |
| Trailing decimal | 0.0 required | 1. allowed | price: 100. |
| +Infinity | Not supported | Allowed | max: +Infinity |
| -Infinity | Not supported | Allowed | min: -Infinity |
| NaN | Not supported | Allowed | result: NaN |
| Positive sign | Not supported | +N allowed | offset: +5 |
JSON5 in the Real World
ESLint uses JSON5 for its configuration file (.eslintrc), which allows developers to add comments explaining why rules are configured a certain way:
json5
// .eslintrc (uses JSON5 syntax — comments allowed)
{
// This is a comment explaining the config
extends: ["eslint:recommended"],
rules: {
"no-unused-vars": "warn",
"no-console": "off", // trailing comma OK
},
env: {
browser: true,
node: true,
},
}Using JSON5 in Your Project
javascript
// Node.js — parsing JSON5
const JSON5 = require("json5");
const config = JSON5.parse(`{
name: "my-app",
// comment
version: '1.0.0',
}`);
// Browser — CDN
import JSON5 from "https://unpkg.com/json5/dist/index.min.mjs";
// Webpack / Babel
// Use json5-loader for .json5 files in webpackWhen to Use JSON5
- Config files humans edit — .eslintrc, .babelrc, TypeScript tsconfig.json (which already accepts JSON5-like syntax with comments)
- Annotated configuration — when you need comments to explain each option to future developers
- Reduced diff noise — trailing commas mean adding a new last item changes only one line, not two
- Build tool configs — some build tools natively support JSON5 config files
When NOT to Use JSON5
- API responses — consumers expect standard JSON; JSON5 will break native JSON.parse()
- Data storage — databases, files, and caches should use standard JSON for universal compatibility
- Machine-generated data — tools that serialize objects should use standard JSON
- Public-facing configuration — if external tools or users read your config, standard JSON is safer
- Performance-critical parsing — JSON5 parsing is slower than native JSON.parse() (which is implemented in C++)
Alternatives to JSON5
| Format | Comments | Trailing Commas | Best For |
|---|---|---|---|
| JSON | No | No | APIs, data storage, machine-generated |
| JSON5 | Yes | Yes | Human-edited config files |
| JSONC | Yes | Yes | VS Code settings, TypeScript tsconfig |
| YAML | Yes | N/A | DevOps config (K8s, CI/CD, Ansible) |
| TOML | Yes | N/A | Rust/Python project config files |
| HCL | Yes | Yes | Terraform, HashiCorp tooling |