JSON5 to JSON Converter
Convert JSON5 to standard JSON online. Supports comments, trailing commas, unquoted keys, hex numbers, and all JSON5 features. Free browser tool.
About
JSON5 extends JSON with ECMAScript 5.1 syntax features: unquoted identifier keys, single-quoted strings, trailing commas, hexadecimal integers, Infinity, NaN, and inline or block comments. Standard parsers (JSON.parse) reject all of these. Feeding a JSON5 config file to a strict JSON consumer causes silent failures or crashes in CI pipelines, build tools, and API endpoints. This converter implements a full recursive-descent JSON5 parser entirely in the browser. No data leaves your machine. It tokenizes input character-by-character without eval or Function constructors, so malicious payloads cannot execute.
Output indentation is configurable from 0 (minified) to 8 spaces. The parser reports errors with exact line and column numbers. Limitation: files exceeding ~50 MB may exhaust browser memory on low-end devices. For extremely large config trees, split input into smaller chunks.
Formulas
JSON5 parsing follows a recursive descent strategy. The converter tokenizes input into a stream, then builds a value tree. Conversion to standard JSON uses the native serializer:
Where input is the raw JSON5 string, replacer is NULL (identity), and space is the indentation width (0 - 8).
Non-finite numeric literals are handled with a lossy mapping:
Hexadecimal integers undergo base conversion: v = parseInt(hex, 16). The parser validates identifiers against ECMAScript 5.1 IdentifierName production using Unicode category checks for ID_Start and ID_Continue code points.
Reference Data
| JSON5 Feature | JSON5 Syntax Example | Standard JSON Equivalent | Status in JSON |
|---|---|---|---|
| Unquoted keys | { key: 1 } | { "key": 1 } | Not allowed |
| Single-quoted strings | "hello" | "hello" | Not allowed |
| Trailing commas | [1, 2, 3,] | [1, 2, 3] | Not allowed |
| Single-line comments | // comment | Removed | Not allowed |
| Multi-line comments | /* comment */ | Removed | Not allowed |
| Hexadecimal integers | 0xFF | 255 | Not allowed |
| Leading decimal point | .5 | 0.5 | Not allowed |
| Trailing decimal point | 5. | 5.0 | Not allowed |
| Positive sign | +1 | 1 | Not allowed |
| Infinity | Infinity | null (lossy) | Not allowed |
| NaN | NaN | null (lossy) | Not allowed |
| Multiline strings | "line1\ | "line1line2" | Not allowed |
| Escape: \v | "\v" | "\u000b" | Not allowed |
| Escape: \0 | "\0" | "\u0000" | Not allowed |
| Escape: \x hex | "\x41" | "A" | Not allowed |
| Null value | null | null | Allowed |
| Boolean values | true / false | true / false | Allowed |
| Double-quoted strings | "hello" | "hello" | Allowed |
| Nested objects | { a: { b: 1 } } | { "a": { "b": 1 } } | Allowed (quoted) |
| Arrays | [1, 2, 3] | [1, 2, 3] | Allowed |
Frequently Asked Questions
"Infinity") and parsing them application-side./* ... */) do not nest. A */ sequence inside a block comment terminates it immediately, which will likely cause a parse error on the remaining text. Single-line comments (//) end at the next line terminator.$, _, or a Unicode escape sequence (\uXXXX). Subsequent characters may also include digits and combining marks. Keys like cafΓ© or $price are valid. Keys starting with a digit (e.g., 3dModel) are not and must be quoted."0", "1") may be reordered by some engines per the spec, but this is rare in practice for config files.json5 npm package."hello\β΅world" becomes "helloworld" (no space, no newline). To preserve a newline character, use \n explicitly.