A JSON formatter should do more than insert line breaks into arbitrary text. It must parse the input as strict JSON first. If parsing succeeds, it can serialise the same data with consistent indentation. If parsing fails, changing whitespace would hide the real problem.
The formatter and validator on this site both use the browser's JSON parser. The formatter writes two-space JSON. The validator returns a small report containing valid: true, the format and the top-level type. Neither tool validates an application's schema or business rules.
Know what strict JSON allows
JSON objects use double-quoted property names and colon-separated values. Arrays use brackets. Strings use double quotes with escapes for special characters. Numbers cannot contain comments, units or leading plus signs. Valid values are objects, arrays, strings, numbers, true, false and null.
JavaScript object notation is broader in everyday source code. Single-quoted strings, comments, unquoted keys, undefined, NaN, functions and trailing commas are not valid JSON. A file that works inside a JavaScript build can still be rejected by an API's JSON parser.
A real formatter test
The evidence input was a compact JSON file containing a Boolean, nested object, number and array. The production workspace selected it, used the visible Format JSON action and returned a real download. The test read that Blob, confirmed two-space indentation and parsed it again.
{"project":"Part 8","published":false,"metrics":{"files":3,"formats":["jpg","webp"]}}
became:
{
"project": "Part 8",
"published": false,
"metrics": {
"files": 3,
"formats": [
"jpg",
"webp"
]
}
}
| Check | Recorded result |
|---|---|
| Input size | 85 B |
| Formatted size | 133 B |
| Indentation | 2 spaces |
| Round-trip parse | published remained false and formats remained a two-value array |
| Upload | No data-file upload request observed in Microsoft Edge 156.0.4314.42 |
Formatter, validator and minifier are different jobs
- JSON Formatter, Minifier & Validator formats readable JSON, writes compact JSON or checks syntax and reports the top-level type. It does not apply JSON Schema.
All three reject invalid syntax before producing a success output. Formatting and minification preserve JSON data types, but insignificant whitespace and original escape spelling may change during serialisation.
Read common parse errors systematically
The exact wording comes from the browser's JSON.parse implementation and can differ by engine or version. The tool prefixes that message with Invalid JSON:. In the evidence browser, the invalid sample {"project":"Part 8","published":false,} produced: Invalid JSON: Expected double-quoted property name in JSON at position 38 (line 1 column 39).
- Unexpected token near a closing brace: look for a trailing comma or an unquoted value.
- Property name expected: check missing double quotes, a missing comma or an extra comma.
- Unexpected end of input: check an unclosed string, object or array.
- Bad control character: a literal newline or tab inside a string must be escaped.
- Position or line reference: inspect a small range before that location; the earlier punctuation often caused the failure.
Do not randomly delete the reported character. Parsers frequently notice the problem only when the next token becomes impossible.
Debug a large document without losing the source
- Keep the original and reproduce the error with the validator.
- Use the reported position or line as a starting point.
- Check the preceding string, comma, brace or bracket.
- Reduce a copy to the smallest failing object or array.
- Fix the generating code or export process, not only one produced file.
- Run the formatter and application-level tests after syntax is valid.
The browser tool accepts one .json file up to 20 MB. It reads the full text and parsed value in memory. A command-line streaming parser is a better choice for very large logs or feeds.
Valid syntax is not a valid API payload
{"quantity":"five"} is valid JSON even if an API requires an integer. A syntax validator cannot know required properties, string formats, allowed enum values, numeric ranges or relationships between fields. Those belong to JSON Schema or application code.
After formatting, validate against the destination's published schema and test a non-production endpoint. Also check top-level shape: an API may require an object while the file contains a valid array.
Watch numbers and precision
Browser JSON parsing represents ordinary JSON numbers as JavaScript numbers. Integers beyond the safe integer range can lose precision when parsed and serialised. Long identifiers should usually be strings. Financial and scientific workflows may need decimal or arbitrary-precision handling outside this simple formatter.
Formatting is therefore not a neutral operation for every imaginable numeric document. Compare critical long numbers before and after, and use a specialised parser when exact lexical representation matters.
Format sensitive JSON locally, then inspect the result
API payloads can contain access tokens, customer records or internal configuration. The data engine performs parsing in the browser, and the evidence run observed no upload of the selected file. Page assets and analytics are separate network considerations described in the privacy guide.
Remove secrets when they are not needed, beware clipboard managers and synced download folders, and never paste a production credential into an unreviewed public tool. Local processing reduces one risk; careful secret handling completes the workflow.
Tools used in this guide
These links match the article examples. Review each tool's tested inputs and output limits before conversion.
Format readable JSON, create compact JSON or validate JSON syntax locally with useful parser errors. Free, no upload or signup; not JSON Schema validation.
CSV to JSON
Data
Convert CSV rows to JSON objects locally. The first row supplies keys and cells remain strings; common delimiters are detected. Free, no data upload or signup.
JSON to CSV
Data
Export a JSON array of objects as CSV locally. Columns use the combined keys; nested values become JSON text. Free, no signup or upload. Review spreadsheet imports.
JSON to YAML
Data
Parse standard JSON and serialize nested objects, arrays and primitive values as readable YAML locally. No Worker claim, upload or schema validation; invalid JSON is rejected.