SQL Formatter

Indent SQL statements using your database's syntax conventions.

Input

Processed on your device

How to use SQL Formatter

Indent an SQL query and separate its clauses for easier review. Select the dialect that matches your database so the formatter can interpret platform-specific syntax where supported.

  1. Paste SQL or open a file, select SQL dialect and choose Indentation.
  2. Format and compare the statement against the original before using it.
  3. Select Format and review the result.
Example input
select item,quantity from orders where quantity>0 order by item

Example use

Review a PostgreSQL statement with a nested query to see which conditions apply to the inner and outer result sets. Select MySQL, SQLite or another supported dialect for syntax from those environments.

Output and compatibility

Formatting changes presentation rather than running or optimizing a query. A readable result can still refer to missing columns, use unsupported database features or return unexpected data. Procedural extensions and particular vendor syntax may exceed the selected formatter’s grammar.

Check the statements after you improve readability

Break out joins, aliases and filters so reviewers can see which clauses apply to each subquery. Verify inline comments and quoted strings containing words that look like keywords. For a repository with several dialects, follow the database-specific formatting and normal development checks in the project itself.

Troubleshooting

If valid SQL is rejected, start by checking the dialect and narrowing the input to the query involved. Use your database’s development tools for plan analysis or validation against a live schema.

For already exported structured data, use CSV to SQL or JSON to SQL to prepare a draft import script.

Frequently asked questions

Does it connect to a database?

No connection is made. Formatting runs against the text in the current browser.

Which dialects can I choose?

Standard SQL, PostgreSQL, MySQL, SQLite, Transact-SQL and BigQuery are listed in the interface.

Does formatting improve query speed?

Indentation helps readability. Database planning and query semantics determine speed.

Can I change tabs to spaces?

Choose a compatible Indentation setting and review the output.

Can I export rows from a dump?

Use SQL to CSV for a compatible SQLite script and selected table.

Will it validate table names and data types?

Formatting does not have access to the database schema. Use your project’s usual database tools for those checks.

Find a tool