SQL

SQL Minifier

Collapses a statement to a single line and removes comments, keeping literals intact.

Loading the tool…

Processing happens locally in your browser. What you paste or load is processed by this page and is not uploaded to a server. Nothing is stored unless you use a control that says it stores something, and you can clear anything this site has kept from the privacy page.

How to use this tool

  1. Paste the formatted statement.
  2. Select Minify to collapse it onto one line and drop the comments.
  3. Copy the single-line result into wherever it needs to go.

What sql minifier does

Minifying SQL collapses the statement onto one line and removes comments. It is useful when a query has to travel somewhere that dislikes newlines — an environment variable, a single-line JSON field, a log message, or a migration tool that reads one statement per line.

Minified SQL is harder for a person to read, so treat it as a transport format rather than something to check into a repository. Keep the formatted version as the source of truth; string literals are preserved exactly, so a minified statement runs identically to the one you pasted.

Frequently asked questions

Yes. A line comment cannot survive being collapsed onto one line, because everything after it would be commented out, so both line and block comments are dropped.

It should. String literals are preserved byte for byte and only whitespace between tokens is collapsed. Test anything important, particularly if the original relied on formatting inside a literal.

Prefer not to. A minified statement produces unreadable diffs and hides changes during review. Keep the formatted version as the source and minify at the point of use.