SQL Minifier
Collapse a SQL query onto a single line and strip comments, while keeping strings, quoted identifiers, and semicolons intact, with a character count saved readout.
Minified live as you type. Queries never leave your browser.
Options
Text inside quotes, double quotes, and backticks is always preserved exactly.
Result
How to minify a SQL query online
Paste your SQL
Drop a query or a whole script into the input and the minified single-line version appears immediately below.
Choose what to keep
Toggle whether comments are removed, whether terminating semicolons stay, and whether keywords are forced to uppercase.
Copy the result
Check the character count saved, then use Copy SQL to grab the minified query and paste it into code or a client.
Why use this tool
One line, no comments
Collapses every run of whitespace and newlines into a single space and strips both line comments and block comments, so the whole query fits on one line.
Quoted text is never touched
Content inside single quotes, double quotes, and backticks passes through exactly, including doubled and backslash escaped quotes, so string values and identifiers keep their meaning.
Semicolon control
Keep every semicolon by default, or drop the trailing one at the end while preserving the semicolons that separate multiple statements in a script.
Optional uppercase keywords
Force reserved words like SELECT, FROM, and WHERE to uppercase in one click. Table and column names, including ones written after a dot, are left as you wrote them.
Character count saved
Shows the original size, the minified size, and the percentage saved so you can see exactly how much shorter the query became.
Runs entirely in your browser
Everything happens on your device. Table names, schema details, and literal values are never uploaded.
About this tool
This SQL minifier takes a query or a whole script and squeezes it onto a single line: every run of spaces, tabs, and newlines collapses to one space, line comments and block comments are removed, and the space before each semicolon is dropped. The result is the same statement with the padding gone, which is handy for pasting a query into a string in your code, shrinking a snippet for a bug report, or normalising whitespace so two versions of a statement compare cleanly. It runs the moment you paste, so there is no button to press.
The important part is what it leaves alone. Text inside single quotes, double quotes, and backticks is preserved character for character, including doubled quotes and backslash escaped quotes, so a value like an email address or a path with a comment marker inside it is never mistaken for code. Postgres dollar quoted blocks are kept verbatim too, which means function bodies survive intact. You can keep comments if you prefer, drop just the trailing semicolon while leaving the ones between statements, or force keywords such as SELECT and JOIN to uppercase without recasing your table and column names.
Everything happens on your device, so production queries with real table names and literal values never leave the browser tab. When you want the opposite of this, the SQL formatter pretty prints a query back into readable, indented clauses. For the data your queries return and store, the JSON minifier does the same shrinking job for JSON, and the CSS minifier covers stylesheets.
Frequently asked questions
- What does minifying a SQL query remove?
- Line comments, block comments, indentation, line breaks, and repeated spaces. Each run of whitespace becomes a single space and the query ends up on one line. Keywords, identifiers, and the structure of the statement are unchanged, so the minified query runs the same as the original.
- Will it break strings or quoted identifiers?
- No. Anything inside single quotes, double quotes, or backticks is copied through exactly, and doubled quotes and backslash escaped quotes are understood so the tool knows where a string really ends. A comment marker or a semicolon sitting inside a string is treated as text, not as code.
- How are semicolons handled across multiple statements?
- By default every semicolon is kept, so a script with several statements stays valid. Turn off Keep semicolons and only the trailing semicolon at the very end is dropped, which is useful when you are pasting a single query into code, while the semicolons between statements are left in place.
- Can it uppercase SQL keywords?
- Yes. Turn on Uppercase keywords and reserved words such as SELECT, FROM, WHERE, and JOIN are recased. Table and column names are never changed, and a name written after a dot is left alone so a column that happens to share a keyword spelling is not clobbered.
- Is my SQL uploaded anywhere?
- No. Everything runs in your browser and the query never leaves your device, which matters because real SQL tends to contain table names, schema details, and literal values from production data.
- Is there a limit on query size?
- No fixed limit. Processing happens in your browser tab, so large scripts are bounded by your device memory rather than an upload cap, and the output area scrolls instead of stretching the page.
Related tools
SQL Formatter & Beautifier
Beautify SQL queries with dialect-aware formatting, keyword casing, and indent control.
JSON Minifier
Minify JSON to the smallest single line, with original vs minified byte size and the percentage saved.
CSS Minifier
Strip comments and whitespace from CSS to shrink it, or beautify a minified stylesheet back into readable rules, with a size saved readout.
API Key Generator
Generate cryptographically random API keys and tokens in hex, base62, or base64url, with control over length, an optional prefix, and bulk output.
ASCII Table Reference
The full ASCII character set with decimal, hex, octal, binary, and HTML codes. Search by code, character, or name.
Atbash Cipher
Mirror the alphabet so A swaps with Z, B with Y, and so on. Atbash is its own inverse, so one field both encodes and decodes as you type.