JSON Formatter & Validator
Format, minify and validate your JSON instantly. Everything runs in your browser; this page does not upload the text you paste
Output
How to use this tool
- Paste your JSON into the “Raw JSON Input” box.
- Choose the indentation: 2 spaces, 4 spaces or tab.
- Press Format to pretty-print or Minify to remove all optional whitespace.
- 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 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.90returns as19.9,1E2as100and-0as0. If trailing zeros matter, store such values as strings.
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.