SQL formatter

Beautify SQL queries for MySQL, PostgreSQL, SQL Server, SQLite, Oracle and BigQuery, with keyword case and indent options. Private, in-browser.

Runs in your browser. Nothing you paste is uploaded.

How to use it

  1. Paste your SQL query or several statements.
  2. Choose the dialect: Standard SQL, MySQL, PostgreSQL, SQL Server, SQLite, Oracle PL/SQL or BigQuery.
  3. Pick UPPERCASE, lowercase or As typed keywords, and 2 or 4 spaces of indentation.
  4. Copy the formatted SQL or download it as a .sql file. Minify puts it back on one line.

Readable queries

Queries copied from logs, ORMs and BI tools usually arrive as one long line. Formatting puts each clause (SELECT, FROM, JOIN, WHERE, GROUP BY, ORDER BY) on its own line and indents subqueries, so you can follow the logic, spot a missing JOIN condition and review changes in pull requests. Formatting only changes whitespace and, if you choose, keyword case; it never changes what the query does.

This page uses the open-source sql-formatter library, which understands each dialect's own keywords and syntax, such as backtick identifiers in MySQL, :: casts in PostgreSQL and square brackets in SQL Server.

Your data stays private

Queries often contain table names, customer emails or internal IDs. Here they are formatted in your browser and never sent to a server. If formatting fails, the query may use syntax from another dialect; switch the dialect, or check for a missing quote or bracket near the reported position.

Questions

Does formatting change my query?
No. Only spaces, line breaks and optionally keyword case change. The result runs exactly the same.
Why do I get an error?
The query probably uses syntax from another database. Pick the matching dialect, or look for an unclosed quote or bracket.
Can it format stored procedures?
Yes for most dialects; choose SQL Server for T-SQL and Oracle PL/SQL for PL/SQL.
Is what I paste sent to a server?
No. The tool runs as JavaScript in your browser. Your text, files and keys stay on your device, so it is safe to use with internal data, tokens and customer records. It keeps working offline after the page has loaded once.

More free tools