Skip to content
MaxyTools

JSON: format, validate, minify and convert to CSV without errors

Updated · 3 min read

· Updated on

JSON is the web's most widespread exchange format: API responses, configuration files, data exports. It is readable by humans, but also very strict, and a single forgotten or superfluous comma is enough to make it unreadable to a program. This guide explains its rules, how to diagnose an error and how to move from one format to another without damaging the data.

The rules to know

A JSON document contains objects ({"key": value}), arrays ([1, 2, 3]), strings, numbers, true, false and null. Nothing else. These rules explain almost every error:

  • Keys and strings use double quotes. Single quotes ('a') are not valid.
  • No comma after the last element of an object or array.
  • No comments. Neither // nor /* */ exists in JSON.
  • No special values such as NaN, Infinity or undefined.
  • Keys must be quoted, unlike JavaScript objects.

Formatting and validating step by step

  1. Paste the JSON into JSON Formatter or drop a file (25 million characters at most). It is indented at once, with 2 spaces, 4 spaces or a tab, and keys can be sorted alphabetically at every level.
  2. Browse the result as coloured code or a collapsible tree; for a big document, the tree opens only the useful levels and shows long lists in batches of 100.
  3. On error, read the message: line, column, excerpt with a caret and likely cause (extra comma, single quotes, unquoted key, comment, NaN).

Why big numbers are a trap

JavaScript represents all numbers as double-precision floats: beyond 9,007,199,254,740,991 (2⁵³ − 1), integers are no longer represented exactly. The identifier 12345678901234567890, read then rewritten by a JavaScript program, becomes 12345678901234567000. Most tools make that detour without saying so. Ours copy numbers as you wrote them: a 20-digit identifier, 92.50 or 1E5 do not change. If your data holds long identifiers, it is better to transmit them as strings.

Common mistakes

  • Copying a JavaScript object (unquoted keys, single quotes) believing it is JSON.
  • Leaving a comma after the last element, a habit from other languages.
  • Pasting JSON with comments from a configuration file (JSONC) into a tool that demands strict JSON.
  • Converting identifiers longer than 15 digits through a tool that rounds them.

Honest limits

  • 25 million characters at most: beyond that, use a command-line tool.
  • Duplicate keys are flagged and kept, but their meaning varies between readers: avoid them.
  • A CSV is a flat format: converting deeply nested JSON loses readability.

Frequently asked questions

Why is my JSON refused when it works in JavaScript?

Because a JavaScript object accepts unquoted keys, single quotes and trailing commas, which JSON forbids.

Is my data sent anywhere?

No. Formatting, validation and conversion run in your browser.

How do I stop Excel running a hidden formula in a CSV?

Our converter prefixes any text starting with =, +, - or @ with an apostrophe. Real numbers are untouched.

Can I put comments in JSON?

No. For commented configuration, use YAML or a derived format such as JSONC, which strict JSON tools refuse.

Which indentation should I choose?

2 spaces is the most widespread convention for the web; 4 spaces or a tab are also common. It is a team convention matter; the meaning of the data does not change.

Tools mentioned in this guide

More guides

These guides are written by the MaxyTools team from how our tools really work. The figures are either calculations you can redo or orders of magnitude labelled as such. Spotted a mistake? Write to us from the Contact page.