LESS FRICTION. MORE FLOW.

SQL Beautifier

Find a SQL style that fits. Compare readable and aligned layouts without rewriting your query.

Explore examples
No sign-up. No query uploads.

SQL Input

0 charactersUTF-8 · SQL
⌘ / Ctrl + Enter

Formatted SQL Output

Waiting for your inputREAD ONLY

Ready when you are. Paste a query to get started.

1 MB input limit · No database connection required

Free to useNo account or subscription.
Three layout presetsReadable, aligned left & aligned right.
Your browser, your codeInput stays in this page.

START WITH SOMETHING SMALL

SQL examples

Load an example, then make it yours.

select id, name, email from users where active = 1 order by name;
select u.name, o.total from users u join orders o on u.id = o.user_id where o.total > 100;
select name from users where id in (select user_id from orders where total > 100);
select name, case when total > 100 then 'Priority' else 'Standard' end as tier from orders;
with recent_orders as (select user_id, total from orders where total > 100) select user_id, sum(total) from recent_orders group by user_id;

A style choice, rather than another formatting shortcut

This SQL beautifier lets you compare three presentation styles for the same query. Readable uses the standard cascading layout. Aligned left and aligned right arrange supported clause keywords into columns. Try a JOIN or a CTE to see where alignment makes a difference. Presets affect the layout, not the data the query requests.

How to choose a beautifying style

Paste SQL, select the database dialect and choose a preset. Set indentation and keyword case before clicking Beautify SQL. Copy or download the result if the style suits your codebase. To compare another style, keep the original input and run the tool again. A one-line SELECT may show little difference between presets; queries with several clauses make alignment easier to evaluate.

Keep team conventions consistent

Use two spaces for compact nesting, four spaces for a wider visual hierarchy or tabs if your team requires them. Uppercase keywords provide a visible contrast with column names. Preserve leaves the original keyword case intact. Avoid changing an entire codebase solely to match this tool: a shared convention is more useful than an isolated aesthetic preference.

What beautifying does and does not change

The engine is sql-formatter 15.10.0. It handles common MySQL, PostgreSQL and T-SQL query syntax but is not a database compiler. It does not rewrite joins, replace subqueries or optimize plans. Unsupported procedural syntax can fail even when it works in your database. Review changes before executing SQL, and keep the original when experimenting with a new style.

Compare with everyday formatting

The SQL Formatter is the shorter path when you only need indentation and keyword case. This page adds explicit layout presets for style exploration. For syntax diagnosis use SQL Validator; to reduce whitespace use SQL Minifier. Browse the tool collection for XML formatting.

Private working copies

The tool sends the input only to a worker running in this page. Library code loads from a CDN. There is no query history or database connection. Files are read locally, limited to 1 MB, and results can be downloaded as .sql. A failed operation leaves the input in place and clears the previous result.

A FEW MORE SHORTCUTS

Keep your workflow moving

Browse all tools

GOOD TO KNOW

Frequently asked questions

How is this different from the SQL Formatter?

This tool adds selectable aligned layout presets. The homepage focuses on everyday indentation and keyword case.

Do all queries look different with each preset?

No. Small queries may produce similar results. Try a multi-clause query to compare alignment.

Does beautifying optimize my SQL?

No. Beautifying changes presentation. It does not measure execution plans or optimize database performance.

What if my SQL uses unsupported syntax?

The tool reports an error and preserves the original input. Some database extensions and stored procedure syntax are outside the formatting library’s coverage.