SQL Minifier
Minify SQL by stripping comments and collapsing insignificant whitespace while keeping every string literal and quoted identifier byte-for-byte, locally in your browser.
- Runs locally in your browser
- No upload required
Capabilities
- Download result
Try it
Supported formats
Privacy
Runs entirely in your browser. Your input is never uploaded, stored, or sent to a third party.
Minified SQL from 64 to 37 character(s).
How it works
- Tokenised the SQL, keeping literals and identifiers opaque.
- Removed comment and whitespace tokens.
- Re-joined the tokens with a space only where it is required.
- String literals and quoted identifiers are preserved byte-for-byte.
Methodology
- Tokenise the SQL, keeping literals, quoted identifiers and comments opaque.
- Drop comment and whitespace tokens.
- Re-join the remaining tokens, inserting a single space only where two tokens would otherwise merge into a different token.
Usage
- Paste SQL that may contain comments or extra whitespace.
- Choose the dialect so the right comment syntax is recognised.
- Run the minifier and copy the compact statement.
Examples
These are examples, not current values: they use fixed inputs, while the interactive tool computes live results in your browser.
Comment and whitespace removal
{
"text": "-- fetch the users\nSELECT id , name\nFROM users WHERE id = 1;",
"dialect": "standard"
}A value containing a comment marker
{
"text": "SELECT '-- not a comment' AS note;",
"dialect": "postgresql"
}MySQL hash comment
{
"text": "SELECT id # trailing note\nFROM users;",
"dialect": "mysql"
}Limitations
Smaller without being wrong
Removing a comment is safe; removing the space between two keywords is not. The minifier decides where a space is required by looking at the tokens either side.
Frequently asked questions
- Does it change my string values?
- No. Single- and double-quoted contents are copied exactly, including spaces and comment markers.
- Can I minify a whole script?
- Yes. Every statement is minified in one pass; statement separators are preserved.
- Is my SQL uploaded?
- No. The statement is processed entirely in your browser.
Sources
- ISO/IEC 9075-1:2023: Information technology, Database languages SQL — ISO/IEC
- PostgreSQL Documentation: SQL Syntax, Lexical Structure — PostgreSQL Global Development Group
- MySQL 8.0 Reference Manual: String Literals — Oracle
- SQLite Documentation: SQL Syntax — SQLite Consortium
- Microsoft Learn: Transact-SQL Syntax Conventions — Microsoft
Send feedback
Tell us if this tool helped, report a problem, or suggest a tool. Only the message you type is sent — never the input you used in the tool.
Was this tool useful?
Prefer to write to us directly? See the contact page.