A JSON5 formatter beautifies JSON5 configuration files while preserving their unique features: comments (// line and /* block */), trailing commas, unquoted keys, and single-quoted strings. Unlike a standard JSON formatter, it does not strip comments.
Formatted JSON5 will appear here...
JSON5 Examples
How to Use the JSON5 Formatter
JSON5 config files from projects using tsconfig, .vscode/settings.json, or custom build configs often contain comments and trailing commas that a standard JSON formatter would strip. A JSON5 formatter preserves all these features while applying consistent indentation.
Step 1: Paste Your JSON5
Copy any JSON5 content — a tsconfig file, a custom config, or a data file with comments — and paste it into the input area. The formatter accepts all JSON5 extensions: // line comments, /* block comments */, trailing commas ({ key: 'value', }), unquoted keys, and single-quoted strings.
Step 2: Format or Minify
Click Format JSON5 to apply indentation while preserving comments in their original positions. Click Minify to strip comments and collapse to a single line — useful for reducing file size before processing.
Step 3: Copy or Download
The formatted output appears with syntax highlighting on the right. Click Copy to clipboard or Download to save as a .json5 file.
JSON5 vs JSON: When to Use Which
Use JSON5 for config files that humans read and edit — tsconfig.json, editor settings, build configurations. The comments and trailing commas make it easier to annotate options and add/remove entries without syntax errors. Use standard JSON for API responses and data interchange where maximum compatibility matters: JSON.parse() cannot parse JSON5 syntax.
FAQ
Is the JSON5 formatter free?
Yes, completely free with no signup required. Format unlimited JSON5 files in your browser.
Is my JSON5 data safe?
Yes. All formatting runs locally in your browser. Your data is never sent to any server.
What is JSON5?
JSON5 is a superset of JSON that extends the syntax to be more human-friendly. Key additions: comments (// and /* */), trailing commas in objects and arrays, unquoted keys, single-quoted strings, hexadecimal numbers, and Infinity/NaN values. It's used in config files like tsconfig.json and package.json5.
Does the formatter preserve comments?
Yes. Both line comments (//) and block comments (/* */) are preserved in their original positions in the output. This is the key difference from a standard JSON formatter.
Can I format minified JSON5?
Yes. Paste minified JSON5 on one line and click Format. The formatter expands it with proper indentation, preserving all JSON5 features including comments and trailing commas.
What is the difference between JSON and JSON5?
JSON is strict: double-quoted keys and strings only, no comments, no trailing commas. JSON5 relaxes these rules for human-readable config files. JSON5 files cannot be parsed by JSON.parse() but can be parsed by the json5 library.
Does the formatter validate JSON5 syntax?
The formatter uses a custom tokenizer that handles JSON5 tokens. Basic syntax errors like unmatched braces or missing colons will be reported. Not all edge cases of the full JSON5 spec may be validated.