tigtools

JSON Formatter

Paste JSON to pretty-print or minify it. If it is not valid, you see what is wrong and where. Your data stays in your browser.

Runs in your browser No sign-up

Indentation

How to use it

  1. Paste your JSON into the input box, or press “Try an example”.
  2. Choose the indentation (2 spaces, 4 spaces or a tab) and, if you like, sort the keys alphabetically.
  3. Read the formatted result on the right. Press Minify to remove all whitespace instead.
  4. If the JSON has a syntax error, fix it at the line and column shown, then copy or download the result as a .json file.

How it works

The formatter parses your text with the browser's built-in JSON parser and writes it out again with the indentation you choose, so the output is always valid, consistently indented JSON. Minify writes the same data with no spaces or line breaks, which is the smallest form for sending over a network or storing in a config value.

When the input is not valid JSON, a small strict checker finds the first problem and reports its line and column, with a plain explanation of common mistakes: trailing commas, single quotes, unquoted keys, comments, and values such as NaN or undefined that exist in JavaScript but not in JSON. Browsers word their own JSON errors differently, so the position is computed by the tool rather than read from the browser message.

Know the limits of re-formatting. Numbers are stored as double-precision floating point, so integers larger than 9,007,199,254,740,991 (2^53 − 1), such as some database IDs, lose precision: 9007199254740993 becomes 9007199254740992. Keep such IDs as strings. If an object contains the same key twice, only the last value is kept. Keys that look like whole numbers ("1", "20") are always placed before other keys by JavaScript, whether or not you sort. Input up to a few megabytes works; above about 300,000 characters live formatting pauses and you press Format instead, so typing stays responsive.

Examples

Reading an API response

A REST API returns one long line such as {"user":{"id":7,"tags":["a","b"]}}. Formatting with 2 spaces puts each key on its own line and nests the tags array, so you can see the structure at a glance.

Comparing two config files

Two JSON configs list the same settings in a different order. Format both with “Sort keys A–Z” turned on; the outputs now line up and a text diff shows only the real differences.

Finding a broken comma

A hand-edited package.json fails to load. Pasting it shows “Trailing comma” at line 14, column 5, pointing at the comma after the last dependency.

Frequently asked questions

Why did a large number change after formatting?

JSON parsers in browsers store numbers as 64-bit floating point, which represents integers exactly only up to 9,007,199,254,740,991. Larger integers are rounded to the nearest representable value. If your data contains 64-bit IDs, transmit them as strings.

Can it format JSON with comments or trailing commas (JSON5, JSONC)?

No. The tool follows the JSON standard (RFC 8259) strictly and reports comments and trailing commas as errors with their position, so you can remove them. That is also what most JSON parsers in programming languages will do.

Does sorting keys change my data?

No values change, only the order of keys inside objects. JSON objects are unordered by definition, so the result is equivalent. Arrays are never reordered, because their order is meaningful.

How large a file can I format?

Files of several megabytes work in a current desktop browser. For inputs above about 300,000 characters the tool waits until you press Format or Minify, instead of reformatting on every keystroke. Very large outputs can make the text box slow to scroll on phones.

Is my JSON uploaded anywhere?

No. Parsing and formatting run in your browser with JavaScript. The text is not sent to a server or stored.

Privacy

Your JSON is parsed and formatted only in your browser. It is not uploaded, logged or stored, and it is not included in analytics.