Code Beautifier & Minifier
Beautify or minify SQL, CSS, JavaScript, HTML and XML with your own indentation and style.
How to use the Code Beautifier & Minifier
- 1Choose the language: SQL, CSS, JavaScript, HTML or XML, and paste your code or drop a file.
- 2Pick Beautify or Minify and adjust the options, such as indentation, keyword case or quote style.
- 3Copy or download the result. Syntax errors are shown with their line and column.
About Code Beautifier & Minifier
The Code Beautifier & Minifier formats and compresses SQL, CSS, JavaScript, HTML and XML. JavaScript, TypeScript, CSS, SCSS, Less and HTML are formatted with Prettier, SQL with sql-formatter and its dialect support, and XML with a formatter that keeps comments, CDATA and entities intact. Paste code or drop a file, pick Beautify or Minify, and copy or download the result.
Each language has its own options. For SQL you choose the dialect, keyword, function and data type case, layout, line breaks around AND and OR, and blank lines between queries. JavaScript options cover semicolons, quotes, trailing commas, arrow parentheses and brace spacing. HTML formatting can keep inline whitespace, format embedded CSS and JS, and place one attribute per line. Minifying JavaScript uses Terser with optional name shortening and code optimization. Syntax errors are reported with line and column.
The code formatter helps when you read minified code from a website, clean up a long SQL query before a review, tidy an XML config or feed, or shrink CSS and JavaScript for a quick deployment without a build pipeline. As an SQL formatter and HTML beautifier in one place, it covers most everyday cleanup jobs.
Frequently asked questions
Which formatters are used?
JavaScript, TypeScript, CSS, SCSS, Less and HTML are formatted with Prettier, SQL with sql-formatter, which knows the syntax of MySQL, PostgreSQL, SQL Server, Oracle, BigQuery and more, and XML with a formatter that keeps comments, CDATA and entities exactly as written.
Is minified code safe to use?
JavaScript is minified with Terser, the minifier behind most build tools. The CSS, HTML, SQL and XML minifiers only remove comments and whitespace that does not matter, so the result behaves exactly like the original.
Why does HTML formatting change the spacing between words?
In HTML, whitespace between inline elements such as links is visible. The default setting keeps it where CSS would render it. Choose "Ignore" only if you do not mind small layout changes.
Is my code uploaded?
No. All formatters run in your browser, so private code and credentials in config files never leave your device.
More in Encode & Format
Encode text and files to Base64 or decode Base64 back, with URL-safe and data URI options.
Percent-encode or decode URLs and query strings, and edit every URL part in a table.
Escape text as named, decimal or hex HTML entities, or decode entities back to text.