How JSON, XML & CSV Formatting Works
Every formatter, minifier, and validator in this family does the same first step before anything else: it fully parses your input using a real parser — JSON.parse for JSON, the browser's own DOMParser for XML. This matters because it means a formatter or minifier can't silently "fix" broken input into something that looks plausible but isn't your actual data; invalid input is rejected immediately, with the same specific error message a dedicated validator would show.
For JSON, both tools first check syntax, then change only whitespace outside strings. Formatting offers 2 spaces, 4 spaces or tabs; minifying removes insignificant whitespace. Numeric spelling, escaped strings, member order and duplicate object members remain unchanged, avoiding the rounding or duplicate-member loss that can occur when converting JSON into JavaScript values and back.
XML works similarly but requires more manual work, since browsers don't expose a built-in "pretty print" for XML the way they do for JSON. XML Formatter walks the parsed document tree and reconstructs it with 2-space indentation by hand; XML Minifier walks the same tree and reconstructs it with no inter-tag whitespace. Both start from a successfully parsed document, so — as with JSON — malformed XML is caught before either tool produces any output.
CSV Formatter and CSV Cleaner take a related but distinct approach, since CSV has no single canonical grammar the way JSON and XML do. CSV Formatter re-parses your file and re-writes it with consistent quoting and line endings (RFC 4180 style), which fixes files with mixed line endings or inconsistent quoting. CSV Cleaner goes further: it trims stray whitespace from every cell and drops fully empty rows — the two most common problems in manually-edited or badly-exported spreadsheets — without touching the actual values in any cell.
For this tool, all of this happens entirely in your browser. Your file is never uploaded to a server, whether it's valid or not.
Related tool
- ToolJSON Formatter
- ToolJSON Minifier
- ToolJSON Validator
- ToolXML Formatter
- ToolXML Minifier
- ToolXML Validator
- ToolCSV Formatter
- ToolCSV Cleaner