GUIDE - Updated 2026-06-25
JSON Formatter vs JSON Validator
The difference between a JSON formatter, validator, and error checker, plus a practical workflow for debugging JSON parse errors.
Open JSON Formatter & Error CheckerQuick Answer
A JSON formatter makes valid JSON easier to read. A JSON validator checks whether the input conforms to JSON syntax. A JSON error checker goes one step further by explaining where parsing failed and what likely caused it.
Use the tools in this order: validate or parse first, fix syntax errors second, then pretty print or minify only after the JSON is valid. Pretty printing cannot rescue invalid JSON because formatting depends on successful parsing.
Comparison
| Tool type | Best for | What it cannot do |
|---|---|---|
| JSON formatter / pretty printer | Indenting valid JSON so nested data is readable | Format invalid syntax |
| JSON minifier | Removing whitespace from valid JSON | Prove that the data shape is correct |
| JSON validator | Confirming whether text is valid JSON | Explain every API or business-rule problem |
| JSON error checker | Finding line, column, and likely parse cause | Guarantee that the server returned the intended payload |
| Schema validator | Checking required fields and types | Fix malformed JSON before parsing |
Debugging Workflow
- Paste the response into JSON Formatter & Error Checker.
- If it is invalid, check the reported line and column before formatting.
- Look for trailing commas, single quotes, unescaped line breaks, missing braces, or HTML responses.
- If the input starts with
<, debug the API endpoint or authentication flow before changing the JSON. - If it is valid, pretty print it and inspect the object or array structure.
- If the syntax is valid but the app still fails, compare the payload against the expected schema or API contract.
Formatter Readiness Checklist
| Check | Why it matters | What to do |
|---|---|---|
| Starts as JSON, not HTML | API errors often return login pages or error HTML. | If the first non-space character is <, inspect status code and response headers. |
| Uses double quotes | JSON strings and object keys require double quotes. | Replace smart quotes or single quotes before parsing. |
| No trailing commas | JavaScript objects may allow them, but JSON does not. | Remove commas after the final array item or object property. |
| No comments | JSON syntax does not include comments. | Move notes outside the payload or use a different config format. |
| Valid before minifying | Minifiers preserve structure only after parsing succeeds. | Validate first, then minify or pretty print. |
Pretty Print vs Validation vs Error Detection
Pretty printing is a readability step. Validation is a syntax gate. Error detection is a debugging workflow.
If a tool only pretty prints, it should be used after the JSON is already valid. If a tool only validates, it may tell you the input is invalid without explaining the practical cause. A debugging-oriented checker should connect the parse error to likely causes such as HTML returned from an endpoint, a missing quote, a trailing comma, or an incomplete response.
Example
{
"name": "FixData",
"tools": ["csv", "json", "markdown",]
}
This looks close to JSON, but the trailing comma after "markdown" can break parsing. A formatter cannot format it until the syntax is valid.
Common Parse Error Patterns
| Pattern | Likely cause | First check |
|---|---|---|
Unexpected token < | HTML response instead of JSON | Check status code, content type, redirects, and auth errors. |
Unexpected end of JSON input | Empty or incomplete response | Inspect network tab, timeout, and server logs. |
Unexpected token } or ] | Trailing comma or missing value | Check the previous property or array item. |
| Single quotes around keys | JavaScript object literal, not JSON | Use double quotes for keys and strings. |
| Smart quotes or pasted text | Rich text changed quote characters | Paste as plain text or normalize quotes. |
When a Valid JSON Still Fails
A formatter and validator can prove that syntax is valid, but they cannot prove that the payload matches your app's contract. After syntax passes, check required fields, nullability, number precision, date formats, and whether the root value is the expected object or array.
For API debugging, keep the raw response, status code, response headers, and a pretty-printed copy. This makes it easier to separate transport problems from JSON syntax problems.
Practical FAQ
Why does pretty print fail on my JSON?
Pretty print usually needs to parse the input first. If the JSON has a trailing comma, missing quote, unescaped newline, or HTML response, the formatter cannot build a structure to indent.
Is a JSON validator the same as a schema validator?
No. A JSON validator checks syntax. A schema validator checks whether valid JSON follows a specific shape, such as required fields, allowed values, and expected data types.
Why does Unexpected token < appear in JSON parsing?
The response is often HTML, not JSON. Common causes include a login page, 404 page, proxy error, framework error page, or endpoint returning the wrong content type.
Should I minify JSON before validating it?
No. Validate or parse first, then minify. If you minify broken JSON with a string-based tool, you can make the error harder to locate.
Can a formatter fix JSON automatically?
It can re-indent valid JSON, but it should not guess missing data or silently rewrite invalid syntax. Use the error location to fix the source payload intentionally.
Related Tool
Related Articles
Updated
2026-06-25
Official references
These official references were used to verify the criteria discussed in this article.
- JSON.parse()MDN Web Docs - Checked: 2026-06-25
- JSON.stringify()MDN Web Docs - Checked: 2026-06-25
- RFC 8259: The JavaScript Object Notation (JSON) Data Interchange FormatRFC Editor - Checked: 2026-06-25