Format, beautify, and minify SQL queries. Keywords uppercased, clauses on new lines.
Input SQL
The SQL Formatter takes minified, single-line, or messy SQL and rewrites it into clean, indented, readable statements. It capitalizes reserved keywords (SELECT, FROM, WHERE, JOIN, GROUP BY, ORDER BY), places each clause on its own line, aligns nested subqueries, and breaks long comma-separated column lists so you can actually read what a query does.
It is used by backend developers, data analysts, and DBAs who copy queries out of application logs, ORM debug output, or BI tools and need to review or share them. Because everything runs in your browser, it works for standard ANSI SQL as well as dialect-specific syntax from PostgreSQL, MySQL, SQL Server, SQLite, and BigQuery.
A SQL formatter tokenizes the input into keywords, identifiers, literals, operators, and punctuation, then reconstructs the text using layout rules rather than changing the query's meaning. Reserved words are matched against a keyword list and uppercased; major clauses such as SELECT, FROM, WHERE, JOIN, GROUP BY, HAVING, and ORDER BY each start a new line, and their arguments are indented one level below.
Nested subqueries and parenthesized expressions increase the indent depth so the query's structure is visible at a glance. For example, SELECT id,name FROM users WHERE age>18 becomes a block where SELECT id, name sits on one line, FROM users on the next, and WHERE age > 18 below it. Formatting is purely cosmetic: whitespace, casing, and line breaks change, but the tables, columns, filters, and results the database returns stay exactly the same.
No. It only adjusts whitespace, indentation, line breaks, and keyword casing. The tables, columns, conditions, and execution result are identical to the original query.
Yes, it is completely free to use. Formatting runs entirely in your browser using client-side JavaScript, so your queries are never uploaded to a server or stored anywhere.
It handles standard ANSI SQL plus common dialects including PostgreSQL, MySQL, SQL Server (T-SQL), SQLite, and BigQuery. Dialect-specific keywords and quoting styles are recognized during formatting.
Yes. You can paste a script with several statements separated by semicolons, and each statement is formatted independently while keeping the overall order.
It is a formatter, not a linter or query validator. It reindents the text but does not check whether your query is syntactically valid or will run against your database.
Where the option is available, you can switch between 2 spaces, 4 spaces, or tab indentation so the output matches your team's coding standards.
Yes. Placeholders such as ? or :name and both single-line (--) and block (/* */) comments are preserved in the formatted output.