Developer Utility

SQL Formatter

Format complex SQL queries, convert keyword case, minify SQL, remove comments, check statistics, and download SQL files.

Format SQL Code Organize long queries and nested SELECT, JOIN, and WHERE clauses into a readable structure.
Keyword Case & Minify Change keyword case outside quoted text or reduce whitespace. Original case is kept by default.
Statistics & Download Check counts for SELECT, JOIN, WHERE, and other query metrics, then save the result as a .sql file.

SQL Query Input

Paste the SQL query you want to format or convert, then choose the options you need.

SELECT 0 JOIN 0 WHERE 0 0 lines 0 chars Compression 0%

Choose the database rules before formatting. Quoted text, comments and operators are handled separately. PostgreSQL assumes standard_conforming_strings=on; MySQL assumes default backslash escapes. This is not a syntax validator or SQL runner. GO, DELIMITER and COPY STDIN scripts are not supported. Input is processed in this browser, up to 200,000 characters.

Conversion Result

Review formatted, minified, or keyword-converted SQL and copy or save it as a file.

Ready
Enter a SQL query, then click Format, Minify, or Keyword Convert.

Compare SQL Workflows

Choose formatting, minifying, keyword conversion, comment removal, or download features based on your task.

SQL Formatter

Organizes SELECT, FROM, JOIN, WHERE, GROUP BY, and ORDER BY clauses with line breaks and indentation.

SQL Minifier

Reduces whitespace outside quoted text. Line-comment endings and newlines between continued strings are retained, so output may have multiple lines.

Keyword Case

Standardizes major SQL keywords as uppercase or lowercase to match team conventions.

Help

What is SQL Formatter?

SQL Formatter is a free developer utility that organizes long single-line SQL queries or complex JOIN, WHERE, and GROUP BY clauses into a readable structure.

Useful for SQL generated by Django ORM, database log queries, admin statistics queries, reporting SELECT statements, SQL reviews, and query refactoring.

Supported Features

  • Line-break formatting for SELECT, FROM, WHERE, JOIN, GROUP BY, and ORDER BY clauses
  • 2-space, 4-space, and tab indentation options
  • SQL keyword uppercase or lowercase conversion
  • Compact whitespace while retaining quoted text and required line breaks
  • Optional ordinary comment removal; executable comments and hints are retained
  • SELECT, JOIN, WHERE, line count, character count, and compression rate statistics
  • Copy formatted results and download SQL files

Useful For

  • Cleaning up single-line SQL logs
  • Analyzing queries from Django ORM or database consoles
  • Understanding queries with many JOIN clauses
  • Separating WHERE, GROUP BY, and ORDER BY conditions clearly
  • Standardizing SQL keyword style for team conventions
  • Saving cleaned queries as .sql files
How do I use auto format?

When enabled, the result area updates automatically using the selected indentation and keyword-case options as you type SQL.

When should I use SQL comment removal?

Comments are kept by default. When enabled, all conversions replace ordinary comments with whitespace. Comment markers inside quoted text and executable comments/hints (/*! */, /*+ */, /*M! */) are retained. MySQL # comments are recognized only in MySQL mode.

What is the difference between uppercase and lowercase keywords?

Quoted strings and identifiers are unchanged. Original case is the default. This is not a SQL parser: unquoted names that overlap keywords cannot always be distinguished. Check names and results in your database when changing case.

How is compression rate calculated?

Compression rate compares the original SQL length with the result SQL length and displays the percentage reduction.

Does it automatically fix SQL syntax errors?

Detects unclosed quotes/comments and some unsupported client scripts. It does not validate or execute SQL, resolve tables/columns, or check all database-specific syntax. Verify the output in your database.

Can I enter sensitive SQL?

SQL and results are processed in browser memory without automatic storage or submission to a conversion server. Copy and download run only when requested. Review results for private data before sharing.