SQL Minifier
Strip comments and collapse whitespace to compress SQL.
Processed locally in your browser. Nothing you enter is uploaded or stored.
- Tokenizes the query rather than using a single regex, so `--` or `/*` inside a quoted string is never mistaken for a real comment.
- Removes line and block comments along with all non-essential whitespace.
- Runs in your browser; queries aren't uploaded.
Why this is private
- Processed locally in your browser. Nothing you enter is uploaded or stored.
- Open your browser's DevTools → Network tab while using this tool — you won't see a request carrying your input, because it never leaves your device.
- Nothing you enter is uploaded to a server or shared with us — the processing happens entirely on your device.
Overview
Strips comments and collapses whitespace in a SQL query to its smallest form, without touching the contents of any string literal.
How to use it
- 1Paste a SQL query.
- 2The minified output updates automatically.
- 3Copy it or download as .sql.
Examples
Formatted to minified
Input
SELECT id, name -- primary key FROM users WHERE active = true
Output
SELECT id, name FROM users WHERE active = true
Tips
- Minifying only removes comments and non-essential whitespace — it never changes a value or identifier inside a string literal, so behaviour is identical.
Frequently asked questions
What people use it for
Shrink a query before embedding it in application codeRemove indentation and comments from a query stored as a string literal or config value.
Prepare a query for a log line or single-line contextCollapse a formatted query into one line without losing meaning.
Clean a query pasted from a tool or ORMStrip generator comments before sharing or storing the query.
Related guides
- How to read JSON with a tree viewerA tree viewer turns a wall of brackets into a structure you can expand, search and copy paths from. Here's how to use one effectively.
- JSON parse errors explained: 'Unexpected token', 'Expected comma or brace', and the restWhat each common JSON error message actually means, the usual cause, and how to find the spot fast using line and column.
- How to format JSON (and actually understand the errors)JSON looks like a JavaScript object but follows stricter rules. Here's what those rules are and how to read the errors when they're broken.
Related tools
All developer toolsSQL FormatterFormat and indent SQL queries for readability.JSON MinifierStrip whitespace to compress JSON to its smallest size.CSS MinifierCompress CSS by removing dead rules, comments and whitespace.JSON Viewer & FormatterView, format, validate, edit and beautify JSON with an interactive tree view.
Ready to use SQL Minifier?
SQL Minifier