Informazioni su SQL Format
SQL Format is a free online SQL formatter with a set of guides on writing readable SQL. This page explains who maintains it, why it exists, how the formatter works and how the project has changed over time.
Who maintains SQL Format
SQL Format is built and maintained by database administrators and developers. The formatting rules come from day-to-day work on production databases: reviewing queries before they ship, reading slow-query logs, tracing a migration that failed halfway through and explaining an execution plan to the developer who wrote the query. Those jobs are much easier when every query in a codebase has the same shape, and that is what the formatter is for.
The guides on this site are written from the same point of view. They focus on conventions that hold up in code review and in version control.
Why it exists
Most SQL is written in a hurry: in a query console, inside a string in application code or generated by an ORM and copied out of a log. It ends up on one long line, or with whatever indentation the author's editor happened to use. Reading that SQL during an incident or a review costs time, and arguing about its layout in pull requests costs more.
A formatter settles the layout question once. You paste the query, pick a handful of options that match your team's style, and get back a version where every clause starts on its own line, joins and conditions are aligned and nesting is visible at a glance. The guide on formatting for code review and version control explains why consistent layout also makes diffs smaller and reviews faster.
We also wanted a formatter that respects your data. Your SQL is formatted in memory and returned. It is not stored, logged or passed to analytics or advertising partners, and there is no account to create. The privacy page has the details.
How the formatter works
The formatter runs on our server. Its engine was ported from an earlier formatter written in Python. When you press Format, it works in three broad steps:
- It tokenizes the SQL: keywords, names, literals, operators, comments and punctuation are recognized, so string literals, quoted identifiers and comments can be left exactly as you wrote them, and multi-character operators such as
->>or::stay in one piece. - It lays out clauses: each major clause such as
SELECT,FROM,WHERE,GROUP BYandORDER BYstarts a new line, select items go one per line, joins are indented underFROMand eachANDorORcondition gets its own line. - It indents nested blocks: subqueries,
CASEexpressions and PostgreSQL function bodies are indented one level deeper than the code around them.
Five options control the result: indent spaces, maximum columns, comma placement, keyword case and parentheses on a new line. The formatter is designed to change only whitespace, line breaks and keyword case, but you should still review the output before running it, as you would with any tool that rewrites code. The FAQ covers the details.
The examples on this site
Wherever a guide or documentation page shows a query "after, formatted by SQL Format", that output was produced by the same engine that runs the formatter, using the options listed in its caption. You can paste the "before" version into the formatter with those options and get the same result. Examples that illustrate a hand-written style, a mistake to avoid or another dialect's syntax are shown as plain code and are not labelled as formatter output.
Project history
A short summary of how the site has developed. The changelog has the full list.
- Version 0.0.1 (September 2026). SQL Format as a standalone site: the formatter with its five options, the contact and privacy pages, a light and dark theme and the interface in sixteen languages.
- Version 2.0.1. A rebuilt formatter page with an options toolbar, an editor with line numbers, Copy and Clear buttons, a status bar and the Ctrl+Enter shortcut, plus layout improvements for
ORDER BYandGROUP BY. - Version 2.3. A cookie banner with a choice between all cookies and essential ones only, a fuller privacy page, the interface opening in your browser's language on the first visit, and 4 spaces as the default indent.
- Version 2.4. Guides on SQL style, documentation for every option, this About page, the FAQ, the terms of use and the changelog, and language-specific addresses such as
/pt-br/and/es/. Version 2.4.1 fixed a series of formatting details, fromNOT EXISTSand leading commas to quoted names and PostgreSQL operators.
Contact
Questions, formatting problems and suggestions are welcome through the contact page. If you are reporting a formatting result you did not expect, include a small query that shows it and the options you used, with any confidential names removed.