SQL Minifier

Compress a query onto a single line and remove comments, for embedding SQL in code, config files, logs or URLs.

Runs in your browser

SQL

Minified SQL

Your SQL is processed in this browser tab and never uploaded.

How to use the SQL Minifier

  1. Paste your formatted SQL into the editor.
  2. Choose whether to remove comments or keep them as /* */ blocks.
  3. Press Minify (Ctrl + Enter).
  4. Copy the one-line result or download it.

Example

Minify a commented query
Input
-- active customers
SELECT id,
       name
FROM customers
WHERE status = 'active'  /* only active */
  AND country = 'NZ';
Result
SELECT id,name FROM customers WHERE status='active' AND country='NZ';

What it does

Safe for literals
A real tokenizer skips string literals, quoted identifiers and Postgres $$ bodies, so 'two spaces' stays exactly as it was.
Comment control
Remove comments entirely, or keep them. Line comments are converted to /* */ so they cannot swallow the rest of a one-line query.
See the saving
The status bar shows how many characters and bytes were removed.

Frequently asked questions

Will minifying break my query?

It should not. The minifier only removes whitespace and comments between tokens, and keeps a space wherever removing it would join two words or create a comment marker such as --.

Why convert -- comments into /* */?

A -- comment runs to the end of the line. On a one-line query, it would comment out everything after it. Block comments end where they should.

Can I turn it back into readable SQL?

Yes. Paste the minified query into the SQL Formatter. Removed comments cannot be recovered, so keep a copy if you need them.