JSON5 Input
Standard JSON
Formatted JSON will appear here.

JSON5 Formatter Online

Format JSON5 files: config files with // comments, trailing commas, and unquoted keys: into clean, standards-compliant JSON. Paste your tsconfig.json, .babelrc, or .eslintrc and get output that works in any JSON parser, API call, or data pipeline.

The problem: every config file breaks standard JSON parsers

The JSON specification deliberately excludes comments. When TypeScript, Babel, ESLint, and VS Code parse their config files, they use custom parsers: not JSON.parse: that strip comments and trailing commas before interpreting the structure. This is convenient for developers writing configs but creates a problem the moment you need to consume that config programmatically: JSON.parse(fs.readFileSync('tsconfig.json')) throws a SyntaxError on the very first // comment.

Common scenarios where this hits: CI scripts reading tsconfig.json paths, linter plugins parsing .babelrc, Webpack config mergers, or any tool that expects strict JSON. This formatter normalizes JSON5/JSONC into strict JSON so those tools receive what they expect.

JSON5 features this tool handles

Single-line comments
// comment text: stripped entirely from output. Works at end-of-line and on its own line.
Multi-line comments
/* block comment */: stripped including all content between /* and */. Safe even if the comment spans multiple lines.
Trailing commas
Commas before } or ] are removed. [1, 2, 3,][1, 2, 3].
Unquoted keys
Bare identifier keys like name:, version:, include: are automatically wrapped in double quotes.

Config files this formatter handles

  • tsconfig.json: TypeScript compiler options (comments + trailing commas)
  • .babelrc: Babel transform configuration (comments, trailing commas)
  • .eslintrc.json: ESLint rules with inline comments explaining decisions
  • jest.config.json: Jest configuration with commented-out transform options
  • .vscode/settings.json: VS Code workspace settings (JSONC format)
  • launch.json, tasks.json: VS Code debug and task configs
  • Any JSONC file: JSON with Comments as used by VS Code extensions

How to use

  1. Paste your JSON5 or JSONC content. Or click Sample for a tsconfig.json example.
  2. Click Format →.
  3. Review the clean JSON output: comments stripped, commas removed, keys quoted.
  4. Copy and use it in any strict JSON parser, API call, or CI pipeline.

JSON5 vs JSONC: what is the difference?

JSONC (JSON with Comments): a minimal extension that adds only two things: single-line (//) and block (/* */) comments, plus trailing commas. Used by VS Code, TypeScript, and most developer tools.

JSON5: a more ambitious superset with a formal specification. Adds everything JSONC supports plus: unquoted object keys, single-quoted strings, hexadecimal numbers (0xFF), leading/trailing decimal points (.5, 1.), positive signs on numbers (+1), and multiline strings with \ continuation. JSON5 is used by some build tools and config systems that want JavaScript-literal-like syntax.

This formatter handles both. For most developers, the relevant features are comments and trailing commas (JSONC). If you have unquoted keys, those are also handled.

Privacy

Formatting runs entirely in your browser: no server receives your config. This matters because config files often contain file paths, module names, plugin lists, or internal project structure information. Nothing is transmitted.

Frequently asked questions

Why does my tsconfig.json throw a SyntaxError in JSON.parse?

tsconfig.json uses JSONC syntax: it can have // comments and trailing commas. JSON.parse follows strict JSON (RFC 8259) which rejects both. TypeScript's own tsc uses a custom parser that handles them. Use this formatter to convert tsconfig.json to strict JSON before passing it to JSON.parse.

What is the difference between JSON5, JSONC, and standard JSON?

Standard JSON: no comments, no trailing commas. JSONC: adds // and /* */ comments and trailing commas. JSON5: adds all of JSONC plus unquoted keys, single-quoted strings, hexadecimal numbers, and leading/trailing decimal points. This formatter handles all three.

Will my comments appear in the formatted output?

No. Comments are stripped because standard JSON has no comment syntax. Use the formatter for one-way conversion: turning a human-edited config into machine-readable strict JSON. Keep your original commented config as the source of truth.

What happens to keys like content-type that are not valid JS identifiers?

Unquoted keys must be valid JavaScript identifiers (letters, digits, underscores, starting with a non-digit). Keys with hyphens like content-type are not valid identifiers and must be manually quoted in the source file: "content-type". The formatter handles valid identifier keys automatically.

Can I automate JSON5 formatting in a CI pipeline without this tool?

Yes: use the json5 npm package (npm install json5) in Node.js: JSON5.parse(fs.readFileSync("tsconfig.json","utf8")) returns a JavaScript object you can then JSON.stringify back to standard JSON. This tool is the browser equivalent for quick one-off conversions.

My file has both // comments and /* */ comments: does the formatter handle both?

Yes. Both single-line (//) and block (/* */) comment styles are stripped. Comments at the end of a line, on their own line, and spanning multiple lines are all handled correctly.

Is the output valid enough to pass a JSON Schema validator?

Yes. The output is strict RFC 8259 JSON. If your source JSON5 is structurally correct (values, types, nesting all valid), the formatted output will pass any JSON Schema validator. Use the JSON Schema Validator tool to verify.

Related tools