SQL Formatter
Format and minify SQL queries with keyword highlighting and dialect support.
Dialect
What the SQL Formatter does
This tool takes a cramped, single-line, or inconsistently cased SQL query and reformats it into a clean, readable layout. It uppercases recognised SQL keywords, places major clauses such as SELECT, FROM, WHERE, JOIN, GROUP BY, and ORDER BY on their own lines, and indents conditional keywords like AND, OR, WHEN, THEN, and ELSE so the structure of the statement is easy to scan.
It is aimed at developers, analysts, and database administrators who paste queries from logs, ORMs, or quick experiments and want them tidied up for review, documentation, or sharing. A Minify button does the reverse, collapsing all whitespace into a compact single line for embedding a query in code or a config file.
How to use it
Pick a dialect (MySQL, PostgreSQL, SQLite, or MSSQL) using the buttons at the top, then paste or type your query into the SQL Input box. Click Format SQL to produce the indented, keyword-cased version, or Minify to compress everything to one line. The result appears in the read-only output area below.
Use Copy Output to put the formatted query on your clipboard, or Clear to reset both boxes. The dialect setting mainly affects keyword handling, for example converting ILIKE to LIKE when SQLite is selected, since SQLite does not support ILIKE.
Notes and limitations
The formatter works by recognising a built-in list of common SQL keywords and functions, then normalising spacing and line breaks around them. It is a lightweight, pattern-based formatter rather than a full SQL parser, so very complex statements with deeply nested subqueries or vendor-specific syntax may not be laid out perfectly, but the output remains valid and equivalent to your input.
Because it only reorganises whitespace and capitalisation, it never changes the meaning of your query, the table or column names, or string literals inside quotes.