Developers

SQL Formatter & Beautifier

Turn a one-line SQL query into readable, consistently indented code. Pick your database dialect, keyword case and indentation, then copy the result.

AdvertisementAd slot: leaderboard-top

Embed this tool

Put this free SQL Formatter on your own website — copy the code below and paste it into your page's HTML.

AdvertisementAd slot: in-content

How to format SQL

  1. Paste a query, or several separated by semicolons, into the left box.
  2. Choose your database dialect so dialect-specific syntax is recognized, then pick keyword case and indentation.
  3. Copy the formatted SQL from the right box.

Why consistent SQL formatting matters

Queries copied from logs, ORMs and BI tools usually arrive as one long line. Formatting puts each clause (SELECT, FROM, JOIN, WHERE, GROUP BY) on its own line and indents conditions and column lists, so you can see the query's structure at a glance and spot problems like a missing join condition.

Teams that agree on a style (for example uppercase keywords and 2-space indents) get cleaner code reviews and diffs, because changes show up as real logic changes rather than whitespace noise. Paste two formatted versions into our diff checker to compare queries.

Formatting is done by the open-source sql-formatter library in your browser, and it only changes whitespace and keyword case, never the logic of your query. Queries containing customer data or credentials stay on your machine.

Need a different tool? Suggest it here — we read every message.

Frequently asked questions

Does formatting change what the query does?

No. Only whitespace, line breaks and keyword case change.

Which databases are supported?

Standard SQL, MySQL, MariaDB, PostgreSQL, SQL Server, Oracle PL/SQL, SQLite, BigQuery, Snowflake and Redshift.

Why do I get a parse error?

The formatter needs syntactically valid SQL for the chosen dialect. Check for unbalanced quotes or parentheses, or try a different dialect.

Is my SQL sent anywhere?

No. It is formatted locally in your browser.

Related tools & templates

AdvertisementAd slot: footer-leaderboard