JSON5 → JSON
Normalize JSON5 to strict RFC 8259 JSON — strips comments, trailing commas, single-quoted strings, unquoted keys, and special numeric literals.
What is JSON5?
JSON5 is a community-maintained superset of JSON that aims to make it easier to write and maintain configuration files by hand. It is specified at json5.org and adds a meaningful set of extensions over strict JSON (RFC 8259), all of which are valid ECMAScript 5.1 syntax.
Input
{
// User configuration
name: 'Alice',
age: 30, // trailing comma
'hobbies': ["reading", "coding",],
active: true,
score: 0xFF,
ratio: .5,
}Output
{
"name": "Alice",
"age": 30,
"hobbies": [
"reading",
"coding"
],
"active": true,
"score": 255,
"ratio": 0.5
}JSON5 extensions
| Extension | JSON5 syntax | Strict JSON equivalent |
|---|---|---|
| Single-line comment | // comment | (removed) |
| Block comment | /* comment */ | (removed) |
| Trailing comma (object) | { "a": 1, } | { "a": 1 } |
| Trailing comma (array) | ["a", "b",] | ["a", "b"] |
| Single-quoted string | 'hello' | "hello" |
| Unquoted key | { name: "Alice" } | { "name": "Alice" } |
| Hexadecimal integer | 0xFF | 255 |
| Positive infinity | Infinity | null (with warning) |
| Negative infinity | -Infinity | null (with warning) |
| Not a number | NaN | null (with warning) |
| Leading decimal | .5 | 0.5 |
| Trailing decimal | 1. | 1.0 |
| Multi-line string | "line1\ line2" | "line1line2" |
Warning: JSON has no representation for
Infinity or NaN. This tool converts both to null and emits a warning. If you need to preserve these values, consider encoding them as strings before converting.JSON5 vs JSONC vs JSON
| Feature | JSON | JSONC | JSON5 |
|---|---|---|---|
| Comments | No | Yes | Yes |
| Trailing commas | No | Yes | Yes |
| Single-quoted strings | No | No | Yes |
| Unquoted keys | No | No | Yes |
| Multi-line strings | No | No | Yes |
| Hex numbers | No | No | Yes |
| Leading/trailing decimal | No | No | Yes |
| Infinity / NaN | No | No | Yes |
Note: JSONC adds only comments and trailing commas. JSON5 adds all JSONC features plus single-quoted strings, unquoted keys, hex numbers, and more. Use the JSONC to JSON tool if your input only uses comments and trailing commas — it is simpler and slightly faster.
Common JSON5 files
| File / Tool | Why JSON5? |
|---|---|
| .json5 files | Explicit JSON5 extension used by libraries and configs that adopt the spec |
| Babel config | Babel can read babel.config.json5 natively |
| Hand-written configs | Authors prefer unquoted keys and comments for readability |
| Test fixtures | Single-quoted strings and inline comments make fixtures more readable |
Frequently Asked Questions
Your files stay on your computer. Dad promised.