Skip to content
Devtoolry

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

  1. Paste SQL.
  2. Review the single-line result.
  3. Copy it into your code or configuration.

Example

Put a query on one line

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

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