CSS / SQL Beautifier
Format and minify CSS stylesheets and SQL queries with dialect support.
What this tool does
CSS and SQL are two of the most widely-used declarative languages in software development, yet both have notoriously inconsistent formatting in practice. This tool normalizes both with dialect awareness, applying consistent indentation, line breaks, and keyword casing so the output is immediately readable and reviewable.
For SQL, the beautifier supports the major dialects (PostgreSQL, MySQL, SQLite, and standard SQL) and properly formats JOINs, subqueries, CTEs, and window functions. For CSS, it handles nested selectors, custom properties, and modern at-rules like @container and @layer. The minifier output strips comments and unnecessary whitespace to produce the smallest valid file for production deployment.
Usage Example
-- Before
select u.id, u.name, count(o.id) as order_count from users u left join orders o on o.user_id = u.id where u.created_at > '2024-01-01' group by u.id, u.name having count(o.id) > 5 order by order_count desc;
-- After (PostgreSQL dialect)
SELECT
u.id,
u.name,
COUNT(o.id) AS order_count
FROM
users u
LEFT JOIN orders o ON o.user_id = u.id
WHERE
u.created_at > '2024-01-01'
GROUP BY
u.id,
u.name
HAVING
COUNT(o.id) > 5
ORDER BY
order_count DESC;Common Edge Cases
- SQL dialects use different operators: || for string concatenation in PostgreSQL/SQLite vs CONCAT() in MySQL. The beautifier does not translate syntax, only formatting.
- CSS custom property values containing semicolons inside parentheses (e.g., background: linear-gradient(...)) can confuse naive minifiers, though this tool handles them correctly.
- Comments inside SQL strings (-- inside a string literal) will be incorrectly treated as comments if the parser does not respect string boundaries.
- Vendor prefixes (-webkit-, -moz-) are preserved in their original order, which matters for some legacy browsers that apply the last matching rule.
- Window functions with complex OVER clauses may be reformatted in ways that obscure their partition logic; manual adjustment may be needed.
FAQ
- Will beautifying SQL change its execution plan?
- No. Formatting changes like whitespace, capitalization, and line breaks have no effect on the query execution. The database parser ignores them entirely.
- Can it format stored procedures and DDL?
- Yes. CREATE FUNCTION, CREATE TRIGGER, CREATE TABLE with complex constraints, and similar DDL statements are formatted with the same rules as SELECT queries.
- Does the minifier rename CSS classes or mangle selectors?
- No. This tool only strips whitespace and comments. For aggressive optimization including selector renaming, use a build-step tool like cssnano or PurgeCSS.