Skip to content

JSON5 Formatter & Validator

Format JSON5 and JSONC, keep comments, and check syntax with exact error positions.

Output
Style
Runs in your browser — your data is not uploaded.

How to use

  1. Paste your JSON5 or JSONC into JSON5 / JSONC input, or click Upload to load a .json5, .jsonc, .json or .txt file.
  2. Choose JSON5 or JSON under Output and pick an Indent: 2 spaces, 4 spaces or Tab. Indent is hidden when Style is Minified.
  3. 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.
  4. Input up to 1 MB is formatted as you type. For larger input, click Format or press Ctrl/Cmd+Enter.
  5. Click Copy to copy the result.

Examples

Reformat tsconfig.json with comments

Input
{
  // Language and environment
  "compilerOptions": {"target": "ES2022", "module": "NodeNext", "strict": true,},
  "include": ["src"],
}
Output
{
    // Language and environment
    "compilerOptions": {
        "target": "ES2022",
        "module": "NodeNext",
        "strict": true,
    },
    "include": [
        "src"
    ],
}

Convert an app config to strict JSON

Input
{
  name: 'storefront',
  port: 0x1F90,
  sampleRate: .5,
  environments: ['staging', 'production',],
}
Output
{
  "name": "storefront",
  "port": 8080,
  "sampleRate": 0.5,
  "environments": [
    "staging",
    "production"
  ]
}

Minify JSON5 settings

Input
// Editor preferences
{
  theme: 'dark',
  fontSize: 14,
  plugins: ['git', 'lint',],
}
Output
{theme:'dark',fontSize:14,plugins:['git','lint']}

What JSON5 allows

FeatureJSON5 exampleStrict 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 numbers0xFF255
Leading/trailing dot, plus sign.5, 5., +10.5, 5, 1
Infinity and NaNInfinity, -Infinity, NaNNo 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.