How to use JSON Formatter
- Paste JSON or select a local .json or .jsonl file.
- Choose standard or JSON Lines mode, indentation, key sorting, and escaping.
- Review validation details and the tree, then copy or download valid output.
Supported behavior
JSON Formatter and Validator parses one standard JSON value or, in JSON Lines mode, one value per non-empty line. Valid data can be indented with two spaces, four spaces, or tabs, and object keys can be sorted recursively and stably while array order always remains unchanged. The page reports parse status, line and column where available, key and array-item totals, maximum nesting depth, and byte sizes before and after. A collapsible tree supports inspection without changing the serialized output. Duplicate object keys may follow JavaScript parsing behavior but can trigger a warning, and integers beyond the safe range are flagged for possible precision loss. Non-ASCII escaping is optional. Pasted JSON and local .json or .jsonl files are parsed entirely in your browser and are never uploaded. Formatting cannot repair invalid syntax or preserve insignificant source whitespace and key duplication exactly; successful output is a fresh, valid JSON serialization of the parsed value.
- Comments, trailing commas, NaN, and Infinity are not valid standard JSON.
- Parsing follows JavaScript number precision, so unsafe integers can lose exactness and are warned about.
Examples
{"active":true,"user":{"id":7,"name":"Ada"}}
Result: { "active": true, "user": { "id": 7, "name": "Ada" } }
{"id":1}
{"id":2,"ok":true}
Result: Two valid JSON Lines values
Common use cases
- Pretty-print a compact API fixture for code review.
- Validate newline-delimited event records independently.
- Sort nested object keys for a deterministic configuration snapshot.
Frequently asked questions
Does sorting keys reorder arrays?
No. Object keys can be sorted recursively, but array order is mandatory and preserved.
What is JSON Lines mode?
Each non-empty line is validated and formatted as its own JSON value.
Can it repair malformed JSON?
No. It reports the parse error and does not fabricate corrected data.
Why is there a duplicate-key warning?
JavaScript parsers usually retain one value for repeated keys, which can hide source data even when parsing succeeds.

