SQL Formatter
Format SQL for MySQL, PostgreSQL, SQLite and more with consistent indentation and keyword case.
Paste SQL and press Format, or use Ctrl/⌘ + Enter.
What this tool does
Paste a long or minified query and get readable SQL back: one clause per line, nested subqueries indented, columns in SELECT lists and JOIN conditions each on their own line, and keywords in the case you prefer. Pick the dialect that matches your database so dialect-specific syntax such as backticks in MySQL, square brackets in SQL Server, double-colon casts in PostgreSQL or Oracle's PL/SQL blocks is understood correctly. Several statements separated by semicolons are formatted together, with a configurable number of blank lines between them. The output keeps your table and column names exactly as written; only whitespace and keyword case change.
Tips and common questions
- If you see "Parse error at token", the query contains syntax the chosen dialect does not know. Try "Standard SQL" or the dialect the query was written for.
- UPPERCASE keywords are the most common convention in documentation and style guides; lowercase is popular with PostgreSQL users. "Keep case" leaves them untouched.
- The formatter changes layout only. It never rewrites, reorders or optimises your query, so the result is safe to run as-is.
- Comments (-- and /* */) are preserved and stay attached to the statement they belong to.
- Parameter placeholders such as ?, $1, :name and @name are recognised and left alone.
- The formatting library is about 500 KB and is downloaded only the first time you press Format.
Privacy
Your SQL stays in the browser. Queries containing real table names, customer data or credentials are never transmitted.