Paste your query
A single statement or several, from a log, an ORM or an editor.
Paste a query and get it laid out with each clause on its own line and consistent indentation. Choose your database dialect, the case of keywords and the indentation.
100% private — your text is processed in your browser and never sent to any server.
A single statement or several, from a log, an ORM or an editor.
Database dialect, keyword case and indentation.
Use it in code review, documentation or your editor.
SQL grows into unreadable lines quickly: a query printed by an ORM, copied from a log, written by a colleague in a hurry or squeezed by a tool into a single line. Reading it, reviewing it or debugging it is much easier when every clause has its own line, joins and conditions are indented, and keywords stand out. This formatter reorganises the layout of a query without changing what it does.
SQL is a family of languages rather than a single one. Each database adds its own keywords, functions, ways of quoting names and parameter markers. Selecting the right dialect, among standard SQL, MySQL, MariaDB, PostgreSQL, SQLite, SQL Server, Oracle and BigQuery, helps the formatter recognise them, for example backticks in MySQL, square brackets in SQL Server or the double colon cast in PostgreSQL.
Most style guides write keywords in uppercase so that they stand out from table and column names, and some teams prefer lowercase. You can convert keywords to either or leave them as written. The indentation can be two or four spaces or a tab, to match your team's convention.
The formatter does not check that the SQL is correct for your database, that the tables exist or that the query will run. It changes layout only. Unusual syntax or vendor extensions may occasionally be laid out in a way you would not choose, or reported as an error you can fix by choosing another dialect. It does not optimise queries or rewrite them.
More utilities that also run without leaving your browser.