UnQTools
Developer Runs in your browser

SQL Minifier

Minify and compress SQL queries into a single line — removes comments and redundant whitespace while preserving string literals and quoted identifiers exactly. Dialect-aware (--, #, /* */). 100% client-side.

100% Private Works Offline Instant

About SQL Minifier

Minify and compress SQL queries into a single line — removes comments and redundant whitespace while preserving string literals and quoted identifiers exactly. Dialect-aware (--, #, /* */). 100% client-side. Everything runs locally in your browser — your data never leaves your device.

How to use

  1. Enter your input in the tool above.
  2. Adjust any options to your preference.
  3. Use the Copy or Download buttons to save the result.
  4. Everything happens locally — your data never leaves your browser.

FAQ

How does the SQL minifier protect string literals?

We tokenize the SQL before stripping whitespace, so string literals ('…', "…", `…`, [bracket]) are treated as atomic units. Their contents — including any spaces, --, #, /* */ sequences, or semicolons inside them — are preserved verbatim. Only whitespace between tokens is collapsed.

What comment syntaxes are supported?

Three styles: SQL standard '--' line comments (ANSI/PostgreSQL/SQLite/T-SQL/MySQL), MySQL '#' line comments, and '/* … */' block comments (with PostgreSQL-style nesting). Toggle comment removal on/off; when off, comments are kept in their minified form.

Can I keep newlines between multiple statements?

Yes. By default the minifier outputs a single line, but switch 'Newlines' to 'Keep newlines between statements' and each semicolon-terminated statement goes on its own line. Consecutive semicolons can optionally be normalized to one.

What output modes are available?

Plain minified SQL (default), or a JS/JSON string-escaped variant for embedding SQL inside JavaScript code — useful for query builders, test fixtures, and configuration files. The escaped mode wraps the result in double quotes and escapes ", \, and newlines.

What extra features does this tool have versus others?

(1) Five-dialect tokenizer (ANSI/MySQL/PostgreSQL/SQLite/T-SQL). (2) Toggle comment removal (-- # /* */). (3) Single-line or keep-newlines-between-statements mode. (4) Semicolon normalization. (5) JS/JSON string-escaped output for embedding. (6) String-literal safety (single, double, backtick, bracket). (7) Live byte + percentage savings meter. (8) Statement counter. (9) localStorage history (max 20). (10) Shareable-URL config. (11) Copy / download .sql. (12) One-click sample SQL. Pairs reversibly with the SQL Formatter.

Search tools and actions

Search across all 616 tools, categories, and quick actions.