JSON5 Formatter Online — Format JSON5 Online

Beautify JSON5 documents — comments, trailing commas, unquoted keys, single-quoted strings — for .babelrc, tsconfig.json, ESLint configs, and more. 100% in your browser.

What is a JSON5 Formatter?

A JSON5 formatter parses JSON5 — a JSON superset that allows comments, trailing commas, and unquoted keys — and emits it with consistent indentation. JSON5 was created so that config files (which humans hand-edit) could carry inline documentation and survive trailing-comma diff noise.

Use this formatter to clean up .babelrc, tsconfig.json, ESLint configs, and any tool config that accepts JSON with comments. The formatter parses JSON5 specifics (// comments, /* block */ comments, trailing commas) and produces strict, indented JSON — copy it back as JSON5 or use the strict form directly.

How to format JSON5 — 4 steps

  1. Paste your JSON5. Copy a .babelrc, tsconfig.json, or any JSON5-style config into the Input panel. Click Load Sample to try a Babel config demo.
  2. Click Run. The formatter parses JSON5 client-side and produces 2-space-indented output.
  3. Review the output. The Output panel shows the formatted document, ready to be saved.
  4. Copy the result. Click Copy to paste back into your repo, build config, or editor.

Side-by-side: JSON5 input vs formatted output

JSON5 with comments & trailing commas

{
  // Babel preset
  presets: ['next/babel',],
  plugins: [
    /* must be last */
    'react-native-reanimated/plugin',
  ],
}

Formatted JSON output

{
  "presets": [
    "next/babel"
  ],
  "plugins": [
    "react-native-reanimated/plugin"
  ]
}

JSON5 Aware

Accepts // comments, /* block */ comments, trailing commas, unquoted keys, and single-quoted strings — every JSON5 extension over strict JSON.

Strict JSON Output

Output is RFC 8259 JSON — keys quoted, strings double-quoted, no trailing commas — ready for any strict parser.

Client-Side Only

JSON5 is parsed in your browser. Config files with credentials, registry tokens, or proprietary build settings never leave the device.

Common use cases

  • check_circleFormat a .babelrc or babel.config.json5 with preset and plugin documentation
  • check_circleBeautify a tsconfig.json with comments explaining compiler options
  • check_circleClean up an ESLint config that uses comments to justify rule overrides
  • check_circleFormat a Webpack or Rollup config exported as JSON5
  • check_circleReformat VS Code settings.json (JSONC) with grouped sections
  • check_circleNormalise JSON5 indentation across a monorepo to reduce diff noise
  • check_circleConvert a JSON5 file to strict JSON for a tool that does not accept comments
  • check_circleFormat auto-generated JSON5 from a build tool or scaffolding CLI

JSON5 vs JSON vs JSONC

Strict JSON (RFC 8259) is the wire format — fast, universal, no comments. JSONC adds comments only and is what TypeScript and VS Code use. JSON5 is the most permissive of the three: comments, trailing commas, unquoted keys, single quotes, hex numbers. Use JSON for data interchange and APIs; use JSONC or JSON5 for hand-edited config files where readability matters more than parser portability.

More than formatting

Validate, format, parse, or convert JSON5 and JSON with the rest of OpenFormatter's tools — all browser-side.

Frequently Asked Questions

What is JSON5 and how does it differ from JSON?

JSON5 is a superset of JSON designed for human-edited config files. It permits // and /* */ comments, trailing commas, unquoted object keys, single-quoted strings, multi-line strings via backslash continuation, leading/trailing decimal points, hex numbers, and explicit + signs. Standard JSON.parse rejects all of these — JSON5 parsers accept them.

Which projects use JSON5?

Babel (.babelrc, babel.config.json5), some Webpack configs, JSON5-aware tools, and many internal config systems use JSON5 directly. TypeScript tsconfig.json and VS Code settings.json use JSONC (JSON with comments) which is a JSON5 subset — the formatter handles both.

Does the formatter preserve comments?

The formatter parses JSON5 and re-emits it as 2-space-indented JSON, which strips comments by design. If you need comments preserved, use a JSON5-aware library like the json5 npm package which supports round-trip formatting with comment retention.

Can I convert JSON5 to strict JSON?

Yes. The formatter output is strict RFC 8259 JSON — comments removed, trailing commas removed, keys quoted, strings double-quoted. Paste JSON5, click Run, and copy the output as a valid JSON file your strict parser will accept.

Why are trailing commas useful in config files?

Trailing commas reduce diff noise. Adding a new array or object element without a trailing comma changes two lines (the new line and the previous line which now needs a comma). With trailing commas, only the new line changes — making git history cleaner and merge conflicts rarer.

Is JSON5 faster or slower to parse than JSON?

Slower. JSON.parse is implemented natively in browsers and Node.js. JSON5 parsers are JavaScript libraries that run in user-space. For config files this is irrelevant (parsed once at startup); for hot-path data interchange always use strict JSON.

Is my JSON5 uploaded to your servers?

No. Formatting runs entirely in your browser. Config files containing API keys, registry credentials, or private build settings never leave your device. Verify by opening DevTools → Network and clicking Run — no requests are made.

How is JSON5 different from JSONC?

JSONC (used by VS Code and TypeScript) allows only comments — single-line and block. JSON5 is a strict superset that adds trailing commas, unquoted keys, single-quoted strings, and number extensions on top of JSONC. Every JSONC file is valid JSON5; not every JSON5 file is valid JSONC.

JSON5 Formatter Online — Format JSON5 with Comments