SMIN

SQL Minifier

Clean SQL comments and redundant whitespace

SQL & Database
πŸ”’ 100% client-side β€” your data never leaves this page
Maintained by Evanβ€’Updated: September 30, 2026
Options
Input

Paste SQL first to minify the query immediately; comment retention and readability trade-offs are available in Advanced mode.

Output
Minified SQL will appear here
πŸ”’ Processed locally in your browser
Page reading mode

The full guide also includes pitfalls, worked examples, snippets, FAQs, and related tools for checking results or troubleshooting.

About this tool

Clean SQL comments and whitespace outside protected quoted text. Line comments can retain their newline, so output is not always one line. This lightweight scanner rejects some unsupported constructs and does not validate, execute, optimize, or certify SQL semantics.

Scenario Recipes

01

Keep a SQL line comment from swallowing the next statement

Goal: Check the retained-comment output boundary.

  1. Paste SELECT 1; -- note followed by a newline and SELECT 2;.
  2. Enable Keep -- comments.
  3. Confirm a newline remains after the comment before the second statement.

Result: Quoted content is preserved and retained line comments still terminate at a newline.

Failure Clinic (Common Pitfalls)

The comment option does not preserve optimizer hints

Cause: Block comments are removed, including comment-shaped hints or executable directives.

Fix: Use a dialect-aware tool for those queries, dollar-quoted strings, nested comments or migration scripts; keep readable source.

Production Snippets

Example

text

SELECT 1; -- note
SELECT 2;

Frequently Asked Questions

Will minifying SQL make it execute faster?

This tool only changes query text size and formatting. It does not run SQL, inspect indexes, compare plans or optimize the query. Saved bytes describe uncompressed UTF-8 text rather than database execution performance.

What is preserved inside quoted text?

Single-quoted, double-quoted, backtick and bracket-delimited text is copied as a whole, including internal spaces and comment-like characters. Doubled delimiters and backslash escapes in quoted strings are recognized. SQL dialects differ, so this is not a universal SQL parser or semantic-equivalence guarantee.

What happens to comments and line breaks?

Ordinary block comments are removed. The Keep -- comments option preserves line comments and their terminating newline so the following statement is not swallowed. It does not preserve optimizer hints or executable block comments; do not use this cleanup for queries that rely on those.

Which inputs need a different tool?

Dollar-quoted strings, nested block comments and unclosed quoted text are rejected. Dialect-specific routines, custom delimiters, comment syntaxes and migration scripts should use a dialect-aware formatter or build tool. Keep the original query and verify behavior in the intended database.

Keep browsing