How to Format SQL Online
Choose Standard SQL, PostgreSQL, MySQL, SQLite or Transact-SQL before formatting. Paste the query and press Format SQL, or use Ctrl+Enter from the source field. Unsupported syntax is reported rather than sent to a database. Copy the result or download a .sql file. The source limit is 200,000 characters; use a local formatter for larger scripts.
SQL Indentation and Keyword Casing
Select two or four spaces and choose uppercase, lowercase or preserved keyword casing. Keep one policy across a repository to reduce distracting diffs. Quoted strings and identifiers have different rules from keywords and should retain their intended meaning. Review the output when a dialect uses case-sensitive identifiers or functions. Formatting cannot infer a team's naming convention or database schema.
Formatting SELECT and JOIN Queries
A SELECT list is easier to scan when each expression is separated clearly from FROM, JOIN, WHERE and GROUP BY. Check aliases and join conditions in the formatted output, especially when multiple tables contain similar column names. A neatly indented query can still multiply rows unexpectedly or omit a required filter. Use the database's execution plan and tests for correctness and performance.
Formatting INSERT, UPDATE and CREATE Statements
Formatting INSERT statements helps align target columns with values. UPDATE and DELETE statements still require careful review of their WHERE clauses; layout does not make them safe to execute. CREATE statements expose constraints and types more clearly, but the formatter does not verify their availability in your database version. Preserve comments that explain migration intent and test migration scripts in the proper environment.
SQL Formatter vs SQL Validator
A SQL formatter recognizes enough syntax to produce readable whitespace. A database validator checks a query against a specific engine and schema. This tool supplies neither schema validation nor query execution. Parsing success does not prove that a query will run or return the right data. Review changes with Text Diff and use your database's own checks before running generated or reformatted SQL.
Standards and references
Frequently asked questions
How do I format a SQL query?
Choose your SQL dialect, paste the query, set indentation and keyword case, then press Format SQL. Copy or download the output.
Does the formatter change query behavior?
Formatting is intended to preserve meaning while changing whitespace and keyword case. Dialect quirks can matter, so review the diff and test important queries before execution.
Which SQL dialects are supported?
This interface offers Standard SQL, PostgreSQL, MySQL, SQLite and Transact-SQL through SQL Formatter.
Can it minify SQL too?
No. This version produces readable SQL. Removing whitespace or comments naively can change tokens or statement behavior.
Is SQL uploaded?
No. SQL is formatted inside your browser and is never executed or uploaded by this tool.