JSON, HTML, CSS, JavaScript, or SQL: which formatter?
Pick the formatter by language and know which ones parse safely, which keep licenses, and which never execute code.
Formatters look interchangeable until a document fails to parse. Each language has its own rules, and the safe tools state what they do with scripts, licenses and execution; choosing by file extension rather than by language is how a formatter mangles valid input.
Data and markup: JSON, HTML and XML
The JSON formatter validates and pretty-prints with line-precise errors, while the HTML formatter indents or minifies and keeps scripts verbatim. XML formatting validates structure as it indents, so a successful pass is also a parse check.
Styles and scripts: CSS and JavaScript
The CSS formatter indents tangled stylesheets or minifies them while keeping license comments intact. The JavaScript formatter parses code and never executes it, running in a worker so a large file does not freeze the page.
Queries: SQL by dialect
The SQL formatter understands dialect, keyword case and indent options, so the same query can be laid out for the engine you actually use. Use it for readability and review, not as a validator of query semantics.
Tools covered in this guide
- JSON Formatter & Validator
Pretty-print, minify, and validate JSON with line-precise errors.
- HTML Formatter & Minifier
Indent messy HTML readably or minify it, with scripts kept verbatim.
- CSS Formatter & Minifier
Indent tangled stylesheets or minify them while keeping licenses intact.
- JavaScript Formatter & Minifier
Format or minify JavaScript safely: parsed, never executed, in a worker.
- SQL Formatter
Format SQL readably with dialect, keyword-case, and indent options.
Frequently asked questions about code formatters
Does formatting JavaScript execute the code?
No. The formatter parses the source without running it, which is why it can format untrusted snippets safely in the browser.
Will minifying CSS remove my license comment?
The minifier keeps license comments intact by design. Verify the output if your license requires an exact header.
Can a formatter fix invalid SQL?
No. It reformats queries; it does not repair syntax or verify that tables and columns exist.
More guides
- Format XML, validate it, or convert it to JSON?
- JSON formatter, tree viewer, or CSV: which one do you need?
- Read, re-delimit, or convert a CSV: which step comes first?
- Basic meta, Open Graph, or Twitter Card: which tags do you need?
- Bold, italic, cursive, or blackletter: which Unicode style?
- Canonical or hreflang: which duplicate problem are you fixing?