How JSON, XML, and CSV Formatting, Validation, and Minifying Work
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, formatting re-serializes your parsed data with 2-space indentation; minifying re-serializes the same parsed data with no whitespace at all. Both start from the exact same parsed structure — the only difference is the spacing argument passed to JSON.stringify — so the two tools can never disagree about what your data actually contains.
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.
As with every tool on PDFPilot, 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