SQL & Database

SQL Minifier

Minify SQL queries into a single compact line — remove comments, collapse whitespace and optionally uppercase keywords. Handy for embedding queries in code, logs or config. String literals are preserved exactly.

Input
Minified SQL
Output will appear here

About this tool

The SQL Minifier collapses a formatted query into a single compact line — stripping comments, folding runs of whitespace and optionally uppercasing keywords. It is the inverse of a formatter, made for when you need to embed a query somewhere that a multiline block is awkward.

That includes hard-coding a query string in Java or another language, dropping SQL into a single-line log entry, or storing it in a JSON or YAML config field. String literals inside quotes are preserved exactly, so the query still runs the same after minification. Everything happens locally in your browser.

How to use

  1. Paste your formatted SQL into the input area.
  2. Decide whether to also uppercase keywords for a consistent look.
  3. The minifier removes comments and collapses whitespace to one line.
  4. Confirm that quoted string literals in the output are untouched.
  5. Copy the single-line query into your code, log or config file.

Features

  • Collapses multi-line SQL into a single compact line.
  • Removes single-line and block comments from the query.
  • Folds repeated spaces, tabs and newlines into single spaces.
  • Optional keyword uppercasing for a uniform style.
  • Preserves string literals inside quotes exactly as written.
  • Ideal for embedding SQL in code, logs and config files.
  • Runs fully in the browser — nothing is uploaded.

Frequently asked questions

Is my SQL sent to a server when minifying?

No. Minification runs in your browser with JavaScript, so the query and any schema names stay entirely on your device.

Does minifying change what the query returns?

No. Only comments and redundant whitespace are removed. The SQL statements are untouched, so the query produces the same results.

Are string literals affected by whitespace collapsing?

No. Text inside single quotes is preserved exactly, including multiple spaces, so values like addresses or messages are not corrupted.

Why would I want SQL on a single line?

A single line is easier to embed as a string in application code, to fit into one log entry, or to store in a config field where multiline text is inconvenient.

Does it remove both line and block comments?

Yes. Both dash-style single-line comments and slash-star block comments are stripped, leaving just the executable SQL.