On this page
If a string is not JSON, the JSON formatter will not repair it. The page parses with JSON.parse, then pretty-prints with JSON.stringify. That is the whole rule. Comments, single quotes, and trailing commas fail before any indentation is applied.
The text stays in the browser. Nothing in formatJSON or validateJSON sends the payload to XSular.
Input
Output
Input
Output
One value that formats
This input was passed to formatJSON with an indent of 2:
{"city":"Casablanca","temp_c":22}
The function returned:
{
"city": "Casablanca",
"temp_c": 22
}
minifyJSON on that pretty text returned the one-line form again: {"city":"Casablanca","temp_c":22}. The number stayed a number. Keys stayed double-quoted. No key was added and none was dropped.
getJSONStats on that value reported 2 keys, a max depth of 1, and 0 array items. Depth counts nested objects and arrays. A flat object of two fields is depth 1. Stats are not a schema check. They only describe the value that parsed.
Indent 4 and tab are the other two options in the formatter. They only change the whitespace JSON.stringify inserts. They do not change the data.
Four inputs that fail
Each of these was passed to validateJSON. The message is what the function returned. The hint is the separate suggestion string, which was null when the table says none.
| Input | Message | Suggestion |
| --- | --- | --- |
| {name: "Rabat", "temp": 22,} | Invalid JSON: Unexpected token at line 1, column 2 | none |
| {"city":"Rabat",} | Invalid JSON: Unexpected token at line 1, column 17 | Object keys must be wrapped in double quotes. |
| {'city':'Rabat'} | Invalid JSON: Unexpected token at line 1, column 2 | none |
| {"city":"Rabat"} // note | Invalid JSON: Unexpected token at line 1, column 18 | none |
The first failure is an unquoted key. The parser stops at column 2, so it never reaches the trailing comma later in the same line. Fix the quotes first, then parse again.
The second failure is a trailing comma and nothing else. The engine message that feeds the suggestion mentions a double-quoted property name, so the hint talks about quotes. The comma is the actual problem. Treat that hint as a guess, then look at the column number.
Single quotes are not JSON strings. A JavaScript object literal and a JSON text are different languages, and this tool only speaks JSON.
A // comment is an unexpected token. JSON has no comments. If a config file allows them, strip the comments before you paste, or use a parser that documents that extension. This one does not.
Mistakes that look like formatting bugs
Pasting a value that is already a JavaScript expression is the usual one. { city: "Rabat" } is legal in a .js file and illegal here. Quote the key and use double quotes on the string.
A trailing comma is legal in a lot of editors and illegal in JSON.parse. Remove the comma before the closing brace or bracket.
undefined and trailing commas inside arrays fail the same way. NaN is not a JSON number. If you need those, you are not holding JSON.
Very large integers can change when they pass through JavaScript numbers. JSON.parse uses the language number type. A token bigger than Number.MAX_SAFE_INTEGER (9007199254740991) is not a safe integer anymore. The formatter does not switch to big-integer mode.
What the page will not do
It will not fetch a URL and format the response. You paste the text.
It will not keep comments, key order is preserved by the JavaScript engine's parse, and it will not sort keys. The Casablanca example came back in the same key order it went in. Do not treat that as a documented sort.
It will not tell you whether the JSON matches a schema. Validation here means "this text parsed." A payload can parse and still be the wrong shape for your API.
The suggestion list is small. It looks for phrases such as "trailing comma" and "expected double-quoted property name" in the engine message. On the trailing-comma sample above, the displayed line says "Unexpected token" and the suggestion talks about quotes. If the hint and the column disagree, believe the column.
Empty input returns "Input is empty" and the suggestion "Paste or type JSON to validate."
Where this sits next to other tools
Base64 is a different transform. Encoding a JSON text does not make it valid, and decoding Base64 does not format it. If a token is three Base64 segments joined by dots, that is a job for the JWT tool, not for this parser. XML is not JSON either. The XML formatter is the page for a feed or an SVG snippet.

