SQL Formatter

Messy SQL code to aligned, readable, and ready to run

Paste a messy SQL query and get it formatted with clean lines and indentation, ready to run and share with your team. Choose from five dialects: PostgreSQL, MySQL, SQLite, SQL Server, or BigQuery. The tool breaks the query into lines by clauses, indents with two spaces, and capitalizes keywords. The logic remains unchanged, as table names, columns, and values stay exactly as they are. Copy the result or download it as a query.sql file. This is useful before a code review, for reading auto-generated queries, and for documentation. Everything runs in the browser, and your code is never sent to any server.

Frequently asked questions

Which dialects are supported?

Five: PostgreSQL, MySQL, SQLite, SQL Server, and BigQuery. You can try formatting Oracle or other dialects using the closest match, but unique syntax might fail.

Does the tool change the query?

Only the spaces, line breaks, and keyword capitalization. What the query actually does remains identical.

Why am I getting an error?

The parser could not read the query, usually due to syntax from a different dialect or a missing bracket. The English error message indicates where it stopped, and it is worth trying a different dialect.

Can I choose lowercase for keywords?

No. The tool always writes keywords like SELECT and WHERE in uppercase. This is the common convention to distinguish them from table and column names.

Is the code sent to a server?

No. The formatting is done entirely in your browser, so you can safely paste queries containing internal table names.

More tools you might need

All tools in Developers and AI