Skip to main content
Database & SQL Tools

SQL Minifier

Minify SQL by removing unnecessary whitespace and comments, while preserving exactly what the query does.

Paste your SQL query below - this tool strips extra whitespace and comments down to a compact single line, without changing what it does.

Use the SQL Query Formatter if you want the opposite - clean, readable formatting instead of a compact single line.

What Does This Tool Do?

It removes redundant whitespace, line breaks, and comments from a SQL query, collapsing it to a compact form - useful when a query needs to be embedded in a single-line context (like an environment variable or a compact log entry).

Why Use This Tool?

Some contexts (certain config files, single-line log formats, copy-pasting into a chat that mangles line breaks) work better with SQL on one line. This tool compacts it safely without altering what it does.

How to Use It

  1. Paste your SQL query.
  2. Click Minify.
  3. Copy the compact, single-line result.

Limitations

String literals are left untouched (whitespace inside a quoted string is meaningful and never altered) - only whitespace between SQL tokens and comments outside of strings are removed.

Frequently Asked Questions

To put a query on one line - for example inside application code, a config value or a log - and to strip comments before sharing it.

No. Text inside quotes is kept exactly as written, including spaces, so data in the query is not altered.

Yes - paste the minified query into the SQL Query Formatter. Removed comments cannot be recovered, though.
Share this tool: