Code Formatters

SQL Formatter

Format queries for Standard SQL, MySQL, PostgreSQL, or SQLite.

Press Ctrl / ⌘ + Enter to run
Read-only result

Format queries for Standard SQL, MySQL, PostgreSQL, or SQLite.

What this tool does

SQL Formatter uses the fixed version of sql-formatter on the site to perform lexical and syntax-aware formatting of statements. Dialect selection affects the recognition of identifiers, operators, and keywords and should therefore be consistent with the query's target database.

  • Provides Standard SQL, MySQL, PostgreSQL and SQLite.
  • Keywords should be in uppercase, and the indentation can be 2 or 4 spaces.
  • SQL is always text only, no database connection is established.

How to use it

  1. Paste the SQL query.
  2. Select the corresponding SQL dialect and indent width.
  3. Click "Format SQL".
  4. View parsing errors or copy formatting results.

Common uses

  • Organize JOINs, subqueries, and complex WHERE conditions.
  • Unify migration scripts and code review formats.
  • Discover inapplicable syntax through dialect parsing.

SQL Formatter Features

Format query text in Standard SQL, MySQL, PostgreSQL, or SQLite dialects. It is suitable for daily development, debugging, data sorting and code optimization scenarios. The processing results can be directly viewed, copied or downloaded.

FAQ

Will formatting execute the query?

No. SQL Formatter simply parses the query text and adjusts keywords, line breaks, and indentation.

Which dialect should I choose?

Select the database that will actually run the query; start with Standard SQL if you are unsure and want to use a common syntax.

Are stored procedures supported?

sql-formatter is mainly oriented to queries and common statements. Complex stored procedures and custom delimiters may be beyond the scope of support.

Back to Developer Tools