JSON formatter example: a trailing comma
Why a payload that looks almost valid is rejected, and what pretty-printed JSON makes easier to see.
Open JSON Formatter to run this case yourself.
Invalid JSON
{
"name": "John",
"age": 30,
}
Valid JSON
{
"name": "John",
"age": 30
}
The problem
The object looks finished. The last property is age, and the closing brace is present. JSON does not allow a comma after the final property. That trailing comma is a syntax error, not a style preference. JavaScript object literals allow it in many engines; JSON does not.
What the formatter does
CompareStack decodes the paste with PHP’s JSON parser. It does not repair the text. Invalid input is returned with the parser message, which for this case is “Invalid JSON input: Syntax error”. Remove the comma after 30 and submit again.
Valid JSON is pretty-printed with JSON_PRETTY_PRINT, and with Unicode and slashes left unescaped. The corrected object above is that shape: four-space indent, one property per line, no trailing comma.
Why formatting helps debugging
A minified object is one long line, so a missing brace and a wrong value look the same until you expand it. Once the document is valid and indented, a later Text Compare against a known-good payload shows added, removed, and changed lines instead of a single-line character soup. Formatting does not tell you whether the values satisfy an API contract.
When this tool may not be the right choice
- JSON Schema validation. This tool checks syntax only. It does not check required fields, types against a schema, or enum values.
- Repairing broken JSON. A trailing comma, a comment, or a single-quoted string must be fixed in the source. The formatter will not guess a correction.
- JSON5, YAML, or JavaScript object literals. Those are different languages. Comments and trailing commas that are legal there are still invalid JSON.
Processing and privacy
Paste tools also run on the server. The text is sent in the form POST, with a limit of 100,000 characters per field. It is not written into a document library or a user account. Server logs can still record technical request metadata such as IP address and URL. Do not paste secrets, credentials, or personal data you are not allowed to send to a web service.
The Privacy Policy and how processing works are the full description.