SQL formatter

Paste a SQL query and get it laid out with one clause per line and neat indentation. Pick your database dialect, keyword case and indentation. Nothing is uploaded or run.

  • Free
  • No sign-up
  • Runs in your browser

Runs in your browser — your text is never sent to our servers.

How to use SQL Formatter

  1. Paste your SQL query into the input box, or click Open a file to load a .sql file.
  2. Choose the dialect that matches your database; Standard SQL works for common queries.
  3. Choose UPPERCASE, lowercase or as-typed keywords, and 2 or 4 spaces.
  4. Copy the formatted SQL or download it as query.sql.

Features

  • Dialects: Standard SQL, MySQL, MariaDB, PostgreSQL, SQLite, SQL Server, Oracle PL/SQL, BigQuery, Snowflake and more
  • Keywords in uppercase, lowercase or as typed
  • Indentation of 2 or 4 spaces
  • Several statements in one input are formatted one after another
  • Runs in your browser: the query is formatted, never executed or uploaded

Supported formats and limits

  • Maximum input: 10,000,000 characters

Examples

InputResult
select u.id,u.name,count(o.id) as orders from users u left join orders o on o.user_id=u.id where u.active=1 group by u.id,u.name order by orders desc limit 10;SELECT u.id, u.name, count(o.id) AS orders FROM users u LEFT JOIN orders o ON o.user_id = u.id WHERE u.active = 1 GROUP BY u.id, u.name ORDER BY orders DESC LIMIT 10;
select a from tselect a from t — Lowercase keywords and 4 spaces.

Limitations

  • The tool only changes layout. It does not run the query, check that tables or columns exist, or optimize it.
  • Very unusual or vendor-specific syntax may not be recognized; if formatting fails, try another dialect.
  • Comments are kept, but their exact position can shift to fit the new layout.

Learn more

SQL is the standard language for querying relational databases, and long queries quickly become hard to read when written on one line. Formatting places major clauses such as SELECT, FROM, WHERE and GROUP BY on their own lines and indents the columns and conditions beneath them, so the structure of the query is visible at a glance.

Consistent formatting helps code review and debugging: it is easier to spot a missing join condition or a misplaced parenthesis. It also makes differences between two versions of a query clearer when you compare them.

SQL dialects differ in identifier quoting (backticks, double quotes or brackets), string escaping, operators and extra keywords, which is why the dialect option exists. Keyword case, meanwhile, is purely a style choice; SQL keywords are not case-sensitive, although many teams write them in capitals.

Frequently asked questions

Does formatting change what my query does?

No. Only whitespace, line breaks and (optionally) the case of keywords change. Names and string literals are kept as they are.

Which dialect should I choose?

Pick the database you are writing for. The dialect controls how quoting, operators and special keywords are recognized. Standard SQL is a safe default.

Is my query sent anywhere?

No. The query is formatted in your browser and is not executed or uploaded.

Why does my query fail to format?

The formatter could not understand part of the syntax, for example an unclosed quote or a vendor-specific feature. Check the message, or try another dialect.

Sources

Last reviewed: September 30, 2026