Skip to content
ToolsOnDuty - free online tools
Developer Tools

SQL Formatter

Beautify and indent SQL queries for many dialects.

Free browser toolRuns in your browserNo sign-up
Loading SQL formatter...

About the SQL Formatter

Well-formatted SQL is far easier to read, review and debug than a single long line of keywords and columns.

Paste a query, pick your database dialect, and this tool re-indents it with consistent capitalisation and line breaks.

It supports many dialects including MySQL, PostgreSQL, SQL Server, SQLite and BigQuery, and runs entirely in your browser.

Key features

  • Beautify and indent SQL
  • Ten selectable SQL dialects
  • Consistent keyword formatting
  • Copy and explicit .sql download
  • Runs in your browser

How to use

  1. 1Pick your SQL dialect.
  2. 2Paste or load your query and run Format SQL.
  3. 3Review the formatted text; remember that formatting does not execute or semantically validate it.
  4. 4Copy or download the .sql result.

Examples

Format a query
Input: select id,name from users where active=1 order by name
Output: Indented SQL with SELECT, FROM, WHERE and ORDER BY separated

Choose the matching SQL dialect for the most appropriate keyword rules.

Frequently asked questions

Which SQL dialects are supported?
Standard SQL plus MySQL, PostgreSQL, MariaDB, SQLite, SQL Server (T-SQL), Oracle PL/SQL, BigQuery, Snowflake and Spark SQL.
Does it run my query?
No. It only formats the text of your query. It never connects to a database or executes anything.
Does it validate the SQL?
It focuses on formatting, not validation, so it tidies the query without checking whether it would run successfully.

Open a related tool to prepare your files or refine the finished result.