Shiklo Tools
PDF40
Image20
Calculators & Converters25
Text & Writing13
Developer26
Video14
Audio14
Document14
Data & Spreadsheet12
Web & SEO9
OCR & Scanning5
Archive & File12
Security & Privacy23
Health & Medical29
QR & Barcode5

SQL Minifier

Minify SQL: remove comments and extra whitespace outside strings to put queries on one line — for code, configs and logs.

Formatted SQL is easy to read, but sometimes you need the opposite: a query on a single line to embed in application code, a JSON or YAML configuration file, an environment variable, a command-line call or a log message. The SQL Minifier strips -- and /* */ comments and collapses all the spacing and line breaks down to what the database needs, while leaving every string literal and quoted name exactly as written.

It works with the SQL of any database — MySQL, PostgreSQL, SQL Server, Oracle, SQLite and others — because it only removes whitespace and comments rather than rewriting the query. You can keep several statements on one line or put each statement on its own line. Your queries are processed in the browser and never sent anywhere.

How to use SQL Minifier

  1. Paste SQL, open a .sql file, or press Sample.
  2. Choose whether to put each statement on its own line.
  3. The minified SQL appears as you type, with the size saved.
  4. Copy it or download it as a file.

Features

  • Removes -- line comments and /* */ block comments.
  • Collapses spaces, tabs and line breaks.
  • Removes spaces around commas, parentheses, = and other operators.
  • Keeps 'strings', "names", `backtick names` and [bracket names] exactly.
  • Optional: one statement per line.
  • Works with any SQL dialect.
  • Runs in your browser; queries are never sent anywhere.

When a one-line query is useful

Many places expect a query on a single line: string constants in application code, JSON and YAML configuration files, environment variables, .env files, command-line tools such as mysql or psql with an -e or -c option, CSV exports of saved queries, and log or monitoring systems that treat each line as a separate event. Removing comments also keeps internal notes out of logs and configuration. Minified queries are slightly smaller to store and transmit, but databases parse formatted and minified SQL equally fast, so the main benefit is convenience rather than performance. Keep the readable version in your repository and generate the compact one where it is needed.

What changes

Only characters the database ignores are removed. The query keeps the same meaning and returns the same result.

BeforeAfter
-- comment until the end of the lineremoved
/* block comment */removed
Indentation and line breaksa single space where needed
a , b and x = 1a,b and x=1
'Test -- account'kept exactly, including the double spaces

Strings and quoted names are safe

Text inside quotes is data, not SQL, so the minifier copies it without change: single-quoted strings (including doubled quotes such as 'it''s'), double-quoted identifiers, MySQL backtick names and SQL Server bracket names. Comment markers inside a string are not treated as comments, so a value like 'a -- b' survives intact. Spaces next to minus signs, slashes and asterisks are kept to avoid creating a comment marker by accident, for example when an expression subtracts a negative number.

Things to know

Optimizer hints written as comments, such as Oracle's /*+ INDEX(…) */ or MySQL's /*! … */ version comments, are removed along with other comments; leave hint queries unminified if you rely on them. MySQL's # line comments are not recognised as comments. PostgreSQL dollar-quoted function bodies are minified like the rest of the code, which is usually fine but makes them hard to read. As with any automatic change, test the minified query once before using it in production.

Formatting the other way

To turn a one-line query from a log file or application code back into readable SQL, use the SQL Formatter, which indents clauses, puts each column on its own line and can upper-case keywords for many dialects. Together the two tools let you move queries between the readable form you edit and the compact form you store.

Frequently asked questions

How do I minify SQL?

Paste the query or open a .sql file; the minified version appears. Copy or download it.

Are comments removed?

Yes, both -- line comments and /* */ block comments.

Are strings changed?

No. Text inside quotes, backticks and brackets is kept exactly.

Which databases are supported?

Any — the minifier only removes whitespace and comments, which works for every SQL dialect.

Can I keep statements on separate lines?

Yes. Turn on One statement per line.

Is my SQL uploaded?

No. Everything happens in your browser.

How do I make SQL readable again?

Use the SQL Formatter.

Related tools