How to use the JSON formatter tool
- Choose Format, Minify or Validate under Operation.
- Paste the document into the JSON box, or select Example to load a sample with a 16-digit number.
- Select Process JSON to run the chosen operation.
- Read the result: indented text for Format, a single line for Minify, or the message Valid JSON. for Validate.
- Select Copy to copy the output, or Clear to empty the form.
What the JSON formatter changes and what it leaves alone
Most formatters parse the text into objects and print those objects again. That round trip is lossy in JavaScript: every number becomes a 64-bit float, so 9007199254740993 comes back as 9007199254740992, 1.50 turns into 1.5 and 1E5 into 100000. Repeated keys collapse to the last one.
This tool takes a different route. It first checks the input with the browser's JSON parser, then splits the original text into tokens (strings, literals and punctuation) and rewrites only the whitespace between them. Every token is emitted exactly as written, so number spelling, key order, duplicate keys and escapes such as \u00e9 survive.
Format, Minify and Validate compared
All three operations begin with the same strict syntax check, so they accept and reject exactly the same input. The indent width is fixed, and keys are never sorted.
- Format puts each object member and array element on its own line, with two spaces per nesting level and one space after each colon. Empty objects and arrays stay as {} and [].
- Minify removes all whitespace outside strings and returns one line. Spaces inside string values are untouched.
- Validate changes nothing and reports Valid JSON. when the document parses.
A worked example with a number beyond 2^53
The sample document holds the integer 9007199254740993, which is 2^53 + 1 and cannot be stored exactly in a double. Format returns it digit for digit.
Run the same text through JSON.parse and JSON.stringify in a console and the last digit becomes 2. That matters for database IDs, order numbers and other long identifiers that travel through JSON as bare integers.
{"title":"Base64Coding","count":9007199254740993}
{
"title": "Base64Coding",
"count": 9007199254740993
}Why JSON validation fails
The check follows the grammar in RFC 8259 with no extensions. The error text comes from your browser's parser; Chrome and Firefox include the position of the first problem. Typical causes:
- A trailing comma after the last member or element.
- Single quotes around keys or strings, or keys with no quotes at all.
- Comments. Neither // nor /* */ is part of JSON.
- NaN, Infinity, undefined or a leading plus sign on a number.
- Extra text after the closing brace, such as a second document.
- A byte order mark at the start, or an empty input box.
Frequently asked questions
Is my JSON sent to a server?
No. Parsing and formatting run in JavaScript on this page, and the document stays in the browser tab. You can check this in the Network panel of the developer tools while you process a document.
Does formatting change large numbers or decimals?
No. Numbers are copied from the input as text, so long integers, trailing zeros such as 1.50 and exponent forms such as 1E5 come out unchanged. Only the whitespace between tokens is added or removed.
What happens to duplicate keys?
They are kept, in their original order. RFC 8259 says names in an object should be unique, and parsers disagree on which value wins, so the tool does not pick one for you. Validate still reports such a document as valid.
Can I change the indentation or sort the keys?
No. Format always uses two spaces and keeps members in the order they appear. Sorting would alter the document, which this tool is built to avoid.
Can it fix broken JSON?
No. This tool only reformats documents that are already valid. For input with single quotes, unquoted keys or trailing commas, use the JSON repair tool on this site first, then come back to minify or validate the output.
Is there a size limit for the JSON formatter?
The code sets no fixed limit. The practical ceiling is your browser's memory and how responsive a text box stays when it holds that much text.