S
SoSimple.tools
Developer tool

JSON Formatter & Validator

Format, minify and validate your JSON instantly. Everything runs in your browser; this page does not upload the text you paste

Runs in your browser: what you enter stays on your device

Output

Share this tool

How to use this tool

  1. Paste your JSON into the “Raw JSON Input” box.
  2. Choose the indentation: 2 spaces, 4 spaces or tab.
  3. Press Format to pretty-print or Minify to remove all optional whitespace.
  4. Read the status (Valid JSON or Parse Error) with the raw size and node count, then copy the output.

Worked example

Paste {"name":"Ana","tags":["a","b"],} and the status shows Parse Error, because JSON does not allow a trailing comma. Delete the last comma and press Format: the status turns to Valid JSON with a raw size of 31 bytes and 4 nodes ("Ana", the tags array and its two strings). Minify then returns the compact version for use in a request or a config file. Remember that the output is regenerated from the parsed value, so very large integers above 2^53 − 1 can lose precision and repeated keys keep only the last value.

Methodology

The tool validates and re-prints JSON with the browser's built-in JSON.parse() and JSON.stringify(). The grammar is the one in RFC 8259 (and ECMA-404): a document is one value (object, array, string, number, true, false or null), strings and keys need double quotes, and comments, trailing commas, NaN, undefined and numbers with leading zeros are rejected.

What the buttons and counters do: Format re-indents the parsed value with 2 spaces, 4 spaces or a tab; Minify removes all optional whitespace. Raw Size is the UTF-8 byte length of your input after trimming. Total Nodes counts every value nested inside objects and arrays, not the outer container: {"a":[1,2]} has 3 nodes (the array and its two numbers).
Limits of a parse-and-print round trip: The output is regenerated from the parsed value, so it can differ from the input. Integers above 9,007,199,254,740,991 (2^53 - 1) are rounded to the nearest double, so 12345678901234567890 comes back as 12345678901234567000. A number such as 1e999 overflows and is printed as null. If an object repeats a key, only the last value survives, and keys that look like array indexes ("2", "10") are moved to the front in ascending order. Check these cases before you rely on the output for IDs or exact monetary values.

What a JSON formatter will not fix for you

Most formatter frustrations come from expecting the tool to do something it was never built to do. Here are five, with what actually happens here.

  • Expecting Format to repair broken JSON. It only parses and re-prints. Invalid input shows Parse Error, and the output box displays your browser's own error message instead of a fixed version.
  • Pasting log lines or JSON Lines. Two objects on two lines are not one JSON document. {"a":1} followed by {"a":2} fails at the start of line 2. Paste one record at a time, or wrap them in [ ] with commas.
  • Pasting a double-encoded string. If the text starts and ends with quotes and is full of backslashes, such as "{\"id\":7}", it is valid JSON, but it is a single string. The status says Valid JSON, Total Nodes shows 0, and nothing gets indented. Remove the outer quotes and the backslashes first.
  • Expecting Raw Size to shrink after Minify. Raw Size is the byte length of what you pasted, so it does not change. The spaced example { "name": "Ana", "tags": ["a", "b"] } is 37 bytes; its minified output is 31. Paste the output back in to see the new size.
  • Assuming numbers keep their written form. Values are re-printed from their parsed value: 19.90 returns as 19.9, 1E2 as 100 and -0 as 0. If trailing zeros matter, store such values as strings.

Related tools

Frequently asked questions

Is the JSON I paste sent to a server? ▼

This page does not upload it. Parsing and formatting are done by JavaScript running in your own browser, and the page does not store the text. Anything outside the page, such as browser extensions, a shared computer or screen recording, is outside its control, so as a general habit rotate any API key or token you have pasted into an online tool you do not fully trust.

Why does my JSON show a Parse Error? ▼

The usual causes are a trailing comma (as in {"name": "Ana",}), single quotes instead of double quotes, keys without quotes, comments, the values NaN or undefined, numbers with leading zeros such as 007, and raw line breaks or tabs inside a string. The exact wording of the message comes from your browser (Chrome, Firefox and Safari phrase it differently) and normally names the unexpected character or position.

Why did a large number or a repeated key change in the output? ▼

JSON.parse turns every number into a 64-bit floating-point value, which is exact only up to 9,007,199,254,740,991. Longer integers, such as 19-digit database IDs, lose their last digits. When the same key appears twice in an object, the later value replaces the earlier one without any warning. If either matters, keep such values as strings in the source data or compare the output with the original.

Can it open tsconfig.json, VS Code settings or very large files? ▼

Files in JSONC or JSON5 style (comments, trailing commas, single quotes) are not valid JSON and will be rejected until you remove those parts. For size, the limit is your browser's memory and patience: the output is rebuilt on every keystroke, so pasting several megabytes can make the page pause for a moment.