Free Online SQL Minifier
Collapse a Formatted SQL Query Into a Single Compact Line
Need to use SQL Minifier right now?
A carefully formatted, multi-line SQL query is great for reading in a code editor, but sometimes you need it as a single compact line — pasting into a config value, a one-line log statement, or a system that doesn't handle multi-line strings gracefully. This tool strips comments and collapses all whitespace and line breaks down to single spaces.
90 → 73 characters
SELECT id, name FROM users WHERE active = 1 AND created_at > '2024-01-01'
Other tools in Developer Tools
Features
- Runs entirely in your browser
- Privacy-first — your data is never uploaded
- Real-time, instant results
- 100% free, no sign-up required
- Works on desktop, tablet, and mobile
- No installation needed
Who uses this tool?
About SQL Minifier
A carefully formatted, multi-line SQL query is great for reading in a code editor, but sometimes you need it as a single compact line — pasting into a config value, a one-line log statement, or a system that doesn't handle multi-line strings gracefully. This tool strips comments and collapses all whitespace and line breaks down to single spaces.
Both single-line (`--`) and block (`/* */`) SQL comments are removed before whitespace collapsing, so any inline documentation in your query doesn't end up jammed into the minified output. The result is functionally identical SQL, just without the formatting.
Useful for embedding a query into a single-line environment variable, a one-line curl command, or any context where a multi-line formatted query would need to be manually reflowed anyway.
How it works
- Paste your formatted SQL. Multi-line, indented, with or without comments.
- Comments and line breaks collapse. Everything reduces to a single line.
- Copy the compact result. Ready to paste anywhere a single line is needed.
Examples
Minifying a formatted query
Input
SELECT id, name\nFROM users\n-- active only\nWHERE active = 1
Output
SELECT id, name FROM users WHERE active = 1