How to use
- Paste your JSON5 or JSONC into JSON5 / JSONC input, or click Upload to load a .json5, .jsonc, .json or .txt file.
- Choose JSON5 or JSON under Output and pick an Indent: 2 spaces, 4 spaces or Tab. Indent is hidden when Style is Minified.
- Set Quotes, Quote keys and Trailing commas if you want to change them. They are hidden when Output is JSON; Trailing commas is also hidden when Style is Minified.
- Input up to 1 MB is formatted as you type. For larger input, click Format or press Ctrl/Cmd+Enter.
- Click Copy to copy the result.
Examples
Reformat tsconfig.json with comments
{
// Language and environment
"compilerOptions": {"target": "ES2022", "module": "NodeNext", "strict": true,},
"include": ["src"],
}{
// Language and environment
"compilerOptions": {
"target": "ES2022",
"module": "NodeNext",
"strict": true,
},
"include": [
"src"
],
}Convert an app config to strict JSON
{
name: 'storefront',
port: 0x1F90,
sampleRate: .5,
environments: ['staging', 'production',],
}{
"name": "storefront",
"port": 8080,
"sampleRate": 0.5,
"environments": [
"staging",
"production"
]
}Minify JSON5 settings
// Editor preferences
{
theme: 'dark',
fontSize: 14,
plugins: ['git', 'lint',],
}{theme:'dark',fontSize:14,plugins:['git','lint']}What JSON5 allows
| Feature | JSON5 example | Strict JSON |
|---|---|---|
| Comments | // line, /* block */ | Not allowed |
| Trailing commas | [1, 2,] | [1, 2] |
| Unquoted keys | {name: 1} | {"name": 1} |
| Single-quoted strings | 'it\'s' | "it's" |
| Multi-line strings | 'line \↵next' | "line next" |
| Hexadecimal numbers | 0xFF | 255 |
| Leading/trailing dot, plus sign | .5, 5., +1 | 0.5, 5, 1 |
| Infinity and NaN | Infinity, -Infinity, NaN | No equivalent (null or a string) |
FAQ
What's the difference between JSON and JSON5?
JSON5 allows comments, trailing commas, unquoted keys, single-quoted strings, hexadecimal numbers, and Infinity or NaN. Strict JSON does not allow those features. The status line tells you whether your input is also valid JSON.
How do I find and fix JSON5 syntax errors?
Click an error's line and column to move the cursor to that position. Invalid input leaves the output empty; correct the syntax yourself, since the tool does not automatically repair it.
Will formatting round large numbers?
Large numbers are kept exactly. Integers above 9007199254740991 and decimals with more than 17 significant digits get a note warning that JavaScript JSON.parse would round them.
Is my JSON5 data uploaded or saved?
Parsing and formatting run in your browser, and the tool does not upload your input. The input is not saved; your option settings are saved locally.