SQL Minifier
Minify SQL by stripping whitespace, comments, and unnecessary formatting. Copy or download the result without sending data anywhere.
SQL Minifier
This SQL Minifier removes unnecessary whitespace, line breaks, and comments from SQL queries to produce the most compact representation. It reduces query size for embedding in application code, URLs, or storage in configuration files.
The minification runs locally in your browser. Your SQL queries never leave your device, making it safe for processing proprietary database code, stored procedures, or queries that may contain business logic.
How to use
- Paste your formatted SQL query into the input editor.
- Click Minify SQL to strip whitespace and comments.
- View the compact query in the output editor.
- Use Copy for the clipboard, Download for a .sql file, or Clear to reset both editors.
What is SQL minification?
SQL minification is the process of removing all characters from a SQL query that are not required for correct execution. This includes stripping whitespace between tokens, removing line breaks, collapsing indentation, and removing SQL comments (-- and /* */).
Minified SQL is useful when queries need to be embedded as strings in application code, sent as URL parameters, stored in compact configuration fields, or transmitted over APIs where payload size matters.
Input notes
The tool accepts any SQL query. It collapses all whitespace between tokens into single spaces, removes line breaks, and strips both single-line (--) and multi-line (/* */) comments. String literals and quoted identifiers are preserved as-is.
Example
A formatted SQL query is compressed to a single line:
--- Input (formatted) ---
-- Get active users with order counts
SELECT
u.name,
u.email,
COUNT(o.id) AS order_count
FROM
users u
LEFT JOIN orders o ON u.id = o.user_id
WHERE
u.active = 1
GROUP BY
u.id;
--- Output (minified) ---
SELECT u.name, u.email, COUNT(o.id) AS order_count FROM users u LEFT JOIN orders o ON u.id = o.user_id WHERE u.active = 1 GROUP BY u.id;