SQL Minifier
Shorten a query for a compact copy.
About this tool
Line comments and block comments are dropped. Keywords are not rewritten.
String literals that contain comment-like text can be affected by this conservative pass.
How to use it
- Open this page and provide the input it asks for.
- Set the options that are visible, then use Minify SQL.
- Read the result in the panel. Copy it or download it when a file is offered. The input stays in this browser.
Limitations
- String literals that contain comment-like text can be affected by this conservative pass.
Line comments and block comments stripped, then one line
Two comment forms are cut, then spaces collapse
Comments go, and the statement becomes one spaced line. Block comments, from slash-star to star-slash, are deleted. A line comment, from two dashes through the end of that line, is deleted. Whatever remains has its whitespace runs replaced by single spaces, and the ends are trimmed. Empty input is rejected. The result is SQL text in the sense of the output type. It is not sent to a server, and it is not checked for grammar.
The comment cuts do not know about strings. Two dashes inside a quoted literal can start a deletion through the end of the line, taking the rest of the literal with them. A block-comment marker inside a literal can do the same kind of damage. The clause formatter is also weak inside strings, but it does a different job: it lifts a keyword list onto separate lines. This page removes comments and joins lines. Running one and then the other is not a guaranteed identity.
Statements are not filtered
Unlike the formatter, this minifier does not require the text to begin with SELECT, INSERT, UPDATE, or DELETE. Several statements separated by semicolons stay, spaces aside, because nothing here rejects a semicolon. That also means a fragment, a comment-only file, and a dialect this project does not format can still be squeezed. Keywords are not uppercased. Identifiers are not touched except where a comment or a space run overlapped them.
Choose the page by the edit you want
Use this page to drop comments and extra spacing from SQL you already trust. Use the formatter when you want clause lines for one of the four supported statement kinds and you want illegal extras rejected. Neither page knows your tables. A shortened statement can still be wrong. Read it if the source contained dashes or comment markers inside literals.
Privacy
Your input is processed in your browser and is not uploaded to UtilChain. File names, text, and results are not sent to analytics.

