JSON5 Formatter & Validator
Validate, format and convert JSON5 — the JSON superset used in tsconfig.json, .eslintrc, jest.config and Babel configs that allows comments, trailing commas, unquoted keys, single-quoted strings and hex numbers. Pretty-print with 2 or 4 space indent, strip it down to strict JSON, and get a precise error with line/column on invalid input.
Input
Options
How JSON5 output quotes keys and string values.
Output
Guides
What is JSON5?
JSON5 is a superset of JSON designed to be easier for people to write and maintain by hand. It relaxes strict JSON's rules: object keys don't need quotes, // and /* */ comments are allowed, strings can use single quotes, trailing commas are fine, numbers can be hexadecimal or start/end with a decimal point, and Infinity/NaN are valid values. It's the format behind tsconfig.json, most .eslintrc files, Babel and Jest configs, and plenty of other hand-edited config files.
What does this tool do?
Paste JSON5 (or plain JSON, which is already valid JSON5) and get back validated, formatted output:
- Format JSON5 — pretty-print or minify the input while keeping it as JSON5.
- Convert to strict JSON — parse the JSON5 and re-serialize it as standard JSON, stripping comments, trailing commas and any other JSON5-only syntax so it's safe anywhere plain JSON is required.
Every run validates the input first. Malformed input doesn't fail silently — the status box shows the parser's exact error, including the line and column where it broke.
Features
- Output Format — reformat as JSON5, or convert to strict JSON.
- Indent — 2 spaces, 4 spaces, tab, or minified (no indent).
- Sort object keys alphabetically — recursively, for a canonical, diff-friendly ordering.
- Quote Style (JSON5 output only) — double or single quotes.
- Shows which JSON5-only features your input actually uses (comments, unquoted keys, trailing commas, hex numbers, and more).
- Copy or download the result.
How to use it
- Paste JSON5 into the input box — validation and formatting happen instantly.
- Choose whether to keep it as JSON5 or convert to strict JSON.
- Adjust indentation, key sorting and (for JSON5 output) quote style as needed.
- Copy or download the output. If the input is invalid, the status box shows exactly what's wrong and where.
Does converting to JSON keep my comments?
No. Strict JSON has no concept of comments, so converting to JSON drops them — along with trailing commas, unquoted keys and any other JSON5-only syntax — same as any JSON5-to-JSON conversion has to.
Privacy
Parsing and formatting run entirely in your browser. Your data never leaves your device — safe for config files you'd rather not paste into a random website's server.
For a similarly relaxed, human-friendly JSON superset with #/// comments and multiline strings, see the HJSON Formatter & Validator. For strict, spec-only JSON, use the JSON Formatter.
Use it from code
From 3 credits per callREST API
curl -X POST https://api.iotools.cloud/v1/tool/json5-formatter-validator \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"input": "{\n // JSON5 allows comments like this\n name: '…",
"outputFormat": "json5",
"indent": "2",
"sortKeys": "",
"quoteStyle": "double"
}'Swap in your own key from your account. The tool's fields are the body — no wrapper.
Ask an AI agent
Use the IOTools `json5-formatter-validator` tool (JSON5 Formatter & Validator) on this input:
YOUR_INPUT_HEREPaste this at any agent connected to the IOTools MCP server, then add your input.