SQL Formatter

Format and beautify SQL queries with dialect-aware rules. Everything runs in your browser, so your queries never leave the page.

About this SQL formatter

This is a free online SQL formatter. Paste any SQL query into the input panel, pick your dialect, and you'll get a clean, indented version in the output panel. The clause structure (SELECT, FROM, JOIN, WHERE, GROUP BY, ORDER BY, ...) is broken across lines so the query is easy to read and review.

Supported dialects

  • Standard SQL
  • PostgreSQL, MySQL, MariaDB, SQLite
  • SQL Server (Transact-SQL), Oracle (PL/SQL)
  • BigQuery, Snowflake, Redshift

Options

  • Keyword case: UPPER, lower, or preserve the original casing.
  • Indent: 2 spaces, 4 spaces, or tab.
  • Sample: load a representative query that exercises CTEs, joins, and aggregates.

How it works

The tool uses the open source sql-formatter library, loaded into your browser on first use. Tokenization and reformatting are dialect-aware, so reserved words and quoting rules match the database you select.

Privacy

Your SQL never leaves your browser. The whole tool runs locally as JavaScript on this page, so you can safely paste production queries, schema migrations, or anything else without it touching a server.

Frequently asked questions

Does this tool send my SQL anywhere?
No. Formatting happens entirely in your browser. The sql-formatter library is fetched once from a public CDN, but your query text is never uploaded.
Does it validate or execute the SQL?
No. The tool tokenizes and reformats the query, but it does not run it against a database and it does not check semantics like whether a column exists. Use a real database client for that.
Why does my query look different after formatting?
The formatter rewrites whitespace, breaks clauses across lines, and (optionally) changes keyword case. The actual SQL is unchanged, only the layout. If something looks wrong, switch the dialect to match your database.
Can I keep my original keyword casing?
Yes. Set the case selector to "preserve" and the formatter will leave select, SELECT, and Select exactly as written.