SQL Minifier
Compress SQL queries onto a single line online, removing comments and redundant whitespace. Useful for logs, config files and embedding SQL in code.
Runs in your browser · Nothing uploadedFree · No sign-up
Something not working, or missing a feature? Send feedback
About the SQL Minifier
The SQL Minifier compresses queries onto a single line by removing comments and extra whitespace, which is handy for logs, environment variables and code that embeds SQL strings.
Everything runs in your browser, so your input is never uploaded to a server.
How to use the SQL Minifier
- Paste SQL.
- Review the single-line result.
- Copy it into your code or configuration.
Example
Input
-- Active users with recent orders
SELECT u.id,
u.email,
COUNT(o.id) AS orders
FROM users u
JOIN orders o ON o.user_id = u.id
WHERE u.status = 'active' /* skip banned */
AND o.created_at > '2026-01-01'
GROUP BY u.id, u.email;Result
SELECT u.id,u.email,COUNT(o.id)AS orders FROM users u JOIN orders o ON o.user_id=u.id WHERE u.status='active' AND o.created_at>'2026-01-01' GROUP BY u.id,u.email;
Both comment styles are removed and the query fits on one line. The quoted values are unchanged.
Common mistakes
- Comments that carry hints. MySQL optimizer hints are written as /*+ … */ comments and are removed with other comments. Add them back by hand if your query depends on them.
- Using minified SQL as protection. Minifying does not escape values or prevent SQL injection. Always pass user input as query parameters.
- Several statements. Multiple statements end up on the same line, separated by their semicolons. Some clients run only the first statement of a line, so check before pasting.
Works well with the SQL Minifier
- SQL Formatter: make a one-line query readable again.
- JSON to SQL Insert: generate INSERT statements from JSON.
- Text & Code Diff: compare two versions of a query.
Frequently asked questions
Are string literals changed?
No. Whitespace inside quoted strings is kept exactly as written.
Are comments removed?
Yes, both -- line comments and /* block */ comments are removed.
Which SQL dialects work?
Any. The minifier only removes comments and extra whitespace outside quoted strings and identifiers, so MySQL, PostgreSQL, SQL Server and SQLite queries all work.
Is my query uploaded?
No. It is processed in your browser and never sent anywhere.
Guides and tutorials
Related tools
JSON Minifier
Minify JSON online by removing all unnecessary whitespace, and see how many bytes you saved. Invalid JSON is reported with its line and column.
HTML Minifier
Minify HTML online: remove comments and collapse whitespace while keeping pre, textarea, script and style blocks intact. See the size saved instantly.
CSS Minifier
Minify CSS online: strip comments, whitespace and redundant semicolons to shrink your stylesheet, and see the bytes saved. Runs in your browser.
JavaScript Minifier
Minify and mangle JavaScript online with Terser for smaller bundles. Supports modern ES syntax, with compress and mangle options and the size saved.
XML Minifier
Minify XML online by removing whitespace between tags, with an option to keep comments. Malformed XML is reported with its location.
JSON Formatter
Format and beautify JSON with configurable indentation and optional key sorting. Errors are reported with exact line and column.