SQL Minifier

Runs entirely in your browser

Compress SQL by removing comments and unnecessary whitespace. This only rewrites text — it never executes your SQL.

Advertisement

0 Input characters
0 Output characters
Size reduction
Advertisement

What is SQL Minifier?

SQL Minifier removes comments, line breaks and unnecessary whitespace from a SQL query, collapsing it onto a single compact line. It's purely a text transformation and never connects to a database.

How to use SQL Minifier

  1. Paste your SQL query into the Input box.
  2. Click Minify.
  3. Copy the compressed result from the Output box.

Features

  • Strips -- line comments and /* block comments */.
  • Collapses all whitespace to single spaces.
  • Preserves string literals and identifiers exactly.
  • Shows input vs. output size and the percentage saved.
  • 100% client-side — your SQL never leaves your browser.

Example

This query with a comment and line breaks:

SELECT id, name, email
FROM users
-- only active accounts
WHERE status = 'active'
ORDER BY created_at DESC
LIMIT 20;

becomes this single line (116 characters down to 92 — a 21% reduction):

SELECT id, name, email FROM users WHERE status = 'active' ORDER BY created_at DESC LIMIT 20;

Tips for using SQL Minifier

  • SQL Minifier uses the exact same tokenizer as SQL Formatter, so both tools treat strings, quoted identifiers and comments identically — only what happens to the tokens afterward differs.
  • Unlike SQL Formatter, which keeps comments in place, SQL Minifier deletes both -- line and /* block */ comments entirely, since there's no reason to ship them in a minified query.
  • Tokens are still separated by single spaces where needed — for example between a keyword and the identifier that follows it — because removing every space would turn SELECT id into the invalid SELECTid. This is size reduction through removing comments and redundant whitespace, not maximum character-level compression.
  • The live character counts update every time you click Minify, so you can see exactly how much a particular query shrank before copying it.

Is SQL Minifier safe?

Yes. SQL Minifier reuses the exact same string- and identifier-aware tokenizer as SQL Formatter, so comments and whitespace are stripped locally in your browser without ever connecting to a database, executing your query, or leaving your device.

Frequently Asked Questions

Does this execute my SQL?

No. This tool only rewrites the text of your query. It never connects to a database or executes anything.

Are comments removed?

Yes. Both -- line comments and /* block comments */ are stripped, since they aren't needed once the query is minified.

Will minifying change what my query does?

No. Only whitespace and comments are removed — every identifier, literal and operator is preserved exactly.

Related tools