About Code Formatter
Useful for making a minified payload readable again, for checking that a config parses before you ship it, or for stripping a file down for production. Switching language keeps whatever you have already pasted.
Convert a JSON array of objects into clean, spreadsheet-ready CSV in a single paste — column headers are inferred from your object keys and every value is quoted and escaped correctly. Because parsing runs entirely in your browser, even large or sensitive API responses never leave your device.
Paste messy or minified code and instantly beautify, minify or validate JSON, HTML, CSS, SQL, XML and YAML. Beautifying re-indents your source with consistent spacing so it is easy to read and review; minifying strips whitespace and comments to ship smaller files; validating surfaces syntax errors with the exact location so you can fix them fast.
It also doubles as a converter between common data formats — JSON to CSV, CSV to JSON, YAML to JSON and back — which is handy when wiring up APIs, configs or spreadsheets. Converting is where structure mismatches surface: CSV has no nesting, so a nested JSON object has to be flattened or dropped.
Validation errors cluster into a small set worth recognising by shape, because the parser's message often points at the end of the file rather than the mistake. A trailing comma after the last item is legal in JavaScript and illegal in JSON, and is by far the most common cause. Single-quoted strings and unquoted keys are valid JavaScript object literals and invalid JSON, which is why pasting a console-logged object into a config file so reliably fails. NaN, Infinity and undefined have no JSON representation at all, yet serialisers emit them anyway.
Minifying deserves a moment of scepticism. Stripping whitespace shrinks a file, but gzip and Brotli already compress repeated whitespace to almost nothing over the wire, so the real-world saving on a text asset is far smaller than the byte count suggests. Minify what ships to a browser; leave configuration and fixtures readable, since a diff on a minified file is unreviewable and that costs more than the bytes.
Indentation width is worth deciding once and applying everywhere rather than per file. Mixed indentation is invisible until a diff shows every line as changed because someone's editor expanded tabs differently, at which point a one-line fix becomes an unreviewable pull request. Two spaces is the common default for JSON, YAML and web languages, and YAML in particular forbids tabs outright — a tab in a YAML file is a parse error, not a style preference.
Common use cases
- Turning a paginated API response into a spreadsheet a non-technical colleague can filter
- Preparing a bulk-import file for a CRM or billing system that only accepts CSV
- Getting a quick row count and column overview of an unfamiliar JSON export