SQL Minifier
Safely minify SQL with dialect-aware strings, comment controls, casing, byte savings, batch statements, code exports, and validation warnings.
SQL minifier features
Reduce SQL size without damaging quoted values, identifiers, comments, or dialect-specific syntax.
- Dialect-aware tokenizer for PostgreSQL dollar quotes, MySQL escapes, T-SQL brackets, nested comments, and string literals
- Live minification with preserve-comments, preserve-hints, keyword casing, extra compression, and statement-per-line modes
- Byte and percentage savings, line-and-column validation warnings, upload/download, copy, and categorized samples
- Export minified SQL as JavaScript, JSON, Python, Java, C#, Go, or PHP string literals and round-trip beautify output
SQL minifier FAQ
Does SQL minification change quoted values?
No. The tokenizer preserves quoted strings and identifiers, including dialect-specific escapes and dollar-quoted PostgreSQL blocks.
Can I keep SQL comments or hints?
Yes. Enable the comment and hint preservation controls when comments or optimizer directives must remain in the output.
Does minification run locally?
Yes. Processing, validation, statistics, and code-literal exports run in your browser; nothing is sent to a server.
Raw SQL
Minified Output (live)
411 B → 360 B (12% smaller)
Export as code string
const sql = "SELECT u.id, u.name, u.email, '-- not a comment' AS note, COUNT(o.id) AS order_count FROM users u LEFT JOIN orders o ON o.user_id = u.id WHERE u.status = 'active' AND u.balance - - 1 > 0 GROUP BY u.id, u.name, u.email HAVING COUNT(o.id) > 5 ORDER BY order_count DESC; /*+ INDEX(users idx_status) */ UPDATE users SET last_seen = CURRENT_TIMESTAMP WHERE id = 42;";