Format and beautify SQL queries for MySQL, PostgreSQL, SQLite, and Standard SQL. Adjustable indentation, keyword casing, and line breaks. Runs in your browser.
📢 Advertisement
Input SQL
Formatted SQL
📢 Advertisement
Why Format SQL?
SQL written by hand or generated by tools often arrives as a single unindented line, a wall of text, or with inconsistent capitalization. Formatting makes the query structure visible: which clauses are at the top level, which conditions are AND vs OR, where subqueries begin and end, and how the SELECT list is organized. This is critical for debugging slow queries, reviewing code, and onboarding new developers to a codebase.
Choosing the Right Dialect
Each SQL dialect has slightly different syntax. MySQL uses backticks for identifiers, PostgreSQL uses double quotes, SQLite is more permissive. The dialect selector tells the formatter which rules to apply. If you don't know which dialect to pick, Standard SQL is the safest default — it works for the most common queries and won't break valid SQL from any source.
Style Conventions
Most SQL style guides recommend uppercase keywords (SELECT, FROM, WHERE) for visual distinction from column and table names, 2 or 4 space indentation, and a newline before each major clause. The formatter applies these by default, with the option to switch to lowercase or preserve the original casing. Pick one and stay consistent across your project.
When to Minify SQL
Minified SQL is useful for one-liner scripts, log queries, URL parameters, embedded SQL in application code, and any context where whitespace adds bulk without value. For everything else — development, code review, debugging, version control — formatted SQL is far more useful.
Frequently Asked Questions
What SQL dialects are supported?
This tool supports MySQL, PostgreSQL, SQLite, and Standard SQL. Each dialect has slightly different syntax for things like string quoting, identifiers, and function names, and the formatter handles all of them correctly. If you don't know which dialect to pick, Standard SQL is the safest default.
Is my SQL data safe?
Yes. All formatting happens entirely in your browser using JavaScript. The SQL is never sent to any server, never logged, and never stored. Open your browser's network tab to verify — no requests leave your device.
What's the difference between format and minify?
Format adds line breaks, indentation, and uppercase keywords so a single-line query becomes a multi-line structured query. Minify does the opposite: removes all unnecessary whitespace to produce the smallest possible query string. Use formatted SQL for development, code review, and debugging.
Can I format very large SQL files?
The tool handles queries up to a few hundred KB smoothly. For very large SQL files (multi-MB), the formatting may take a few seconds but will complete. The constraint is your browser's memory and string handling.
Does formatting change the query's meaning?
No. The formatter is purely cosmetic — it changes whitespace, line breaks, capitalization, and indentation but never changes the order of tokens, the operators, or the query logic. A formatted query produces exactly the same result as the original.