OnlyFormat

JSON Formatter & Validator

Format, beautify, minify, and validate JSON data. Customize indentation to your preference.

No data sent to server
Indent:
JSON Input
Formatted Output

Related Tools

What is JSON Formatting?

JSON (JavaScript Object Notation) is a lightweight data interchange format widely used in web APIs, configuration files, and data storage. Raw JSON from APIs or minified sources is often a single long line that is difficult to read.

A JSON formatter (also called a JSON beautifier or pretty-printer) adds proper indentation and line breaks to make the structure visible at a glance. This tool also validates your JSON, catching syntax errors like missing commas, unmatched brackets, or trailing commas before they cause issues in your code.

You can choose between 2-space, 4-space, or tab indentation. The minify option removes all whitespace, producing the most compact representation for production use or network transfer.

How to Use

  1. Paste your JSON data into the input box, or click "Sample" to load example data.
  2. Select your preferred indentation (2 spaces, 4 spaces, or tabs).
  3. Click "Format" to beautify the JSON, or "Minify" to compress it.
  4. If there are syntax errors, they will be displayed with the specific error message from the JSON parser.
  5. Copy or download the result.

JSON syntax rules (RFC 8259)

  • Strings: double quotes only — single quotes invalid
  • Keys: must be quoted strings (unlike JS object literals)
  • No trailing commas: [1, 2, 3,] is invalid
  • No comments: // or /* */ not allowed in standard JSON (use JSONC for VS Code-style)
  • Boolean and null: lowercase only — true, false, null
  • Numbers: no leading zeros except 0 itself, no NaN, no Infinity
  • UTF-8 encoded: spec mandates Unicode; UTF-8 BOM is forbidden

Common JSON pitfalls

  • Number precision loss: JavaScript's Number.MAX_SAFE_INTEGER is 2⁵³ - 1 = 9,007,199,254,740,991. Integers above this start losing precision — for large IDs (Twitter snowflakes, PostgreSQL bigints), serialize as strings
  • Date serialization: JSON has no native Date; use ISO 8601 strings and parse on the receiving end
  • Pasting from JS code: JS object literals (single quotes, unquoted keys, trailing commas) are NOT valid JSON
  • Encoding mismatch: receiving Latin-1 data treated as UTF-8 produces mojibake — always specify UTF-8

FAQ

Does it fix invalid JSON automatically?

No — this tool validates strictly. If your JSON has syntax errors (trailing commas, single quotes, unquoted keys), the error message points to the approximate location. Manually fix and re-paste.

What is the maximum JSON size supported?

Browser memory dependent. Up to 50 MB processes smoothly. 100 MB+ may freeze briefly. For multi-GB JSON streams, use jq on the command line.

Does minification change the data?

No — only whitespace is removed. Values, key order, and structure are identical. Format a minified JSON and you get back the same structured output.

2-space vs 4-space vs tab indentation?

Style preference. 2-space is most common in JS/Node ecosystem (Airbnb style). 4-space is more readable for deeply nested data. Tabs let each editor display preferred width but cause issues in CI scripts checking exact bytes.

JSON has no comments — what's the alternative?

JSONC (VS Code's flavor) allows // and /* */ comments — used by tsconfig.json, .vscode/settings.json. JSON5 is a looser superset with comments, trailing commas, single quotes. Both are NOT valid plain JSON — only use where the parser accepts them.

Is my JSON data sent to a server?

No — formatting and validation run entirely in your browser via native JSON.parse / JSON.stringify. Verify in DevTools Network tab.

⚠️ Reference Only

Output is generated based on your input and is provided for reference. Results may vary depending on your specific use case, edge cases, or environment-specific behavior. We do not guarantee accuracy of conversions, validations, or computed values.

Always verify critical outputs against official documentation or production environments. We are not responsible for any decisions or losses based on these tool results.