How to use the SQL Formatter
- Paste one or more SQL statements into the input.
- Choose the database dialect, keyword case and indentation.
- The formatted SQL appears as you type. Copy it or download it as a
.sqlfile.
Why format SQL?
SQL generated by tools, logs and ORMs is usually one long line. Formatting puts each clause on its own line and indents subqueries, so joins, filters and grouping can be read and reviewed. In version control, formatted SQL produces small, clear diffs.
Example
select id, name from accounts where region = 'EMEA' and active = true order by nameSELECT
id,
name
FROM
accounts
WHERE
region = 'EMEA'
AND active = TRUE
ORDER BY
nameChoosing the dialect
Databases quote identifiers and write some keywords differently: MySQL uses backticks, SQL Server square brackets, PostgreSQL double quotes. Choosing the right dialect lets the formatter read those correctly. If parsing fails, try “Standard SQL” or the dialect your database actually uses.
SQL and Salesforce
Salesforce developers meet SQL on the other side of integrations: data warehouses, middleware, Heroku Postgres and external objects through Salesforce Connect. Salesforce’s own query language, SOQL, looks similar but is not SQL — it has no joins in the usual sense and uses relationship paths such as Account.Name instead.
Features and limitations
What it does
- Supports standard SQL, PostgreSQL, MySQL, SQL Server (T-SQL), Oracle (PL/SQL) and SQLite.
- Formats SELECT, INSERT, UPDATE, DELETE, CREATE and multi-statement scripts, including CTEs and window functions.
- Upper-case, lower-case or preserved keywords; 2 or 4 space indentation; standard or tabular layout.
- Comments and string literals are kept exactly as written.
- Explains where parsing failed, with line and column.
What it does not do
- Formatting only: it does not run queries or check them against a database schema.
- Stored procedure bodies with vendor-specific control flow may format less neatly.
- For Salesforce SOQL, use the SOQL Formatter, which understands relationship queries and bind variables.