SQL Formatter

Format messy SQL into readable, indented queries for eight dialects, change keyword case, or minify a query to a single line without touching strings.

Developer Tools Runs in your browser · no upload

Reviewed 23 November 2026 · Free · No account needed

ExecutionYour browserInput never leaves your tab
File retentionNoneNothing is stored
AccountNot requiredNo sign-up, no paywall
PriceFreeNo trial, no usage cap on the tool itself

How to use

  1. Pick Format or Minify.
  2. Paste your SQL, or open a .sql file.
  3. Choose the dialect, indent width and keyword case for formatting.
  4. Copy the result or download it as a .sql file.

Example

Input: select id,name from users where id=1 order by name

Output: SELECT id, name FROM users WHERE id = 1 ORDER BY name

How it works

Formatting uses the open-source sql-formatter library, loaded only when you open this tool, to tokenise the query and lay out clauses on their own lines. Minifying uses a small scanner that removes comments and extra whitespace outside strings.

Format: tokenise by dialect, place each major clause on a new line, indent sub-expressions by your width, apply your keyword case. Minify: copy string literals and quoted identifiers verbatim, drop comments, collapse whitespace, remove spaces around commas, parentheses and semicolons.

Another example

select a,b from t where x=1 becomes SELECT / a, / b / FROM / t / WHERE / x = 1 on separate lines, or select a,b from t where x=1 when minified.

Limits and edge cases

  • The formatter changes layout and keyword case only; it does not validate your query against a database or check table names.
  • Vendor-specific syntax can fail to parse if you pick the wrong dialect.
  • Minify strips comments except optimizer hints such as /*+ ... */.
  • Input is limited to about 1 million characters.
  • Text inside single quotes, double quotes and backticks is never altered, including doubled-quote escapes such as 'it''s'.
  • MySQL and Oracle optimizer hints in /*+ */ and /*! */ comments are kept when minifying.
  • Several statements separated by semicolons are formatted one after another.

Privacy

Your SQL is formatted in this browser tab. It is never sent to a server and no database connection is made.

About this page

Written and reviewed by Toolnexo on 23 November 2026. The limits above describe the published tool, not an idealised version of it. If a result looks wrong or the page is unclear, email [email protected] with the tool URL and what you entered. Corrections are published here.

Related tools

FAQ

Questions about SQL Formatter

How do I format SQL online?

Paste your query into the left box and choose Format. The tool puts each clause (SELECT, FROM, WHERE, GROUP BY and so on) on its own line and indents columns and conditions. You can pick the dialect, 2 or 4 spaces of indent, and upper, lower or unchanged keyword case.

Which SQL dialects are supported?

Standard SQL, MySQL, MariaDB, PostgreSQL, SQLite, SQL Server (T-SQL), Oracle (PL/SQL) and BigQuery. Choose the one that matches your database so vendor-specific syntax, such as backtick quoting or T-SQL variables, is understood.

Does it run or check my query?

No. It only rearranges whitespace and, if you choose, keyword case. It does not connect to a database, run the query, or check that tables and columns exist, so a well-formatted query can still contain mistakes.

When should I minify SQL?

Minifying is handy when you need a query on one line, for example inside a configuration file, a log message or a code string. Comments are removed, so keep the original if you need them.