About SQL Formatter
This SQL formatter is free, needs no sign-up and runs in your browser, so your queries are never uploaded. Paste a query, pick the dialect, and it is rebuilt with each clause on its own line, columns listed one per line and joins and conditions indented.
It supports standard SQL and the dialects of MySQL, MariaDB, PostgreSQL, SQLite, SQL Server (T-SQL), Oracle PL/SQL, BigQuery, Snowflake, Amazon Redshift, DuckDB, Spark, Hive, Trino, ClickHouse, IBM Db2, SingleStore, TiDB and Couchbase N1QL. The dialect matters because each has its own keywords, quoting and functions.
You choose upper, lower or preserved keyword case, an indent of 2, 4 or 8 spaces or a tab, and the alignment style. A minify switch does the reverse: it strips comments and collapses whitespace to a single line. The result can be copied or downloaded as a .sql file.
How to use SQL Formatter
- Paste your SQL into the box. The sample query is replaced as soon as you type.
- Choose the dialect that matches your database.
- Pick the keyword case and the indent width, or switch on Minify for a one-line version.
- Read the result. If the SQL cannot be parsed you get the first line of the error instead.
- Copy the result or download it as query.sql.
Features
- Nineteen dialect options, from standard SQL to cloud warehouses.
- Keyword case: UPPER, lower or kept as written.
- Indent by 2, 4 or 8 spaces, or a tab, with standard or tabular alignment.
- Minify: removes comments and collapses whitespace, leaving strings and quoted names untouched.
- Several statements at once, separated by blank lines.
- Copy and download as a .sql file.
- Formatting happens as you type, with a short delay.
Worked examples
select id,name from users where active=1 and created_at>'2026-01-01' order by name gives SELECT / id, / name / FROM / users / WHERE / active = 1 / AND created_at > '2026-01-01' / ORDER BY / name
Standard SQL, upper-case keywords, 2-space indent. Slashes here stand for line breaks.
SELECT Id FROM Users WHERE Active = 1 gives select / Id / from / Users / where / Active = 1
With lower-case keywords. Names such as Id and Users are not keywords and keep their case.
-- active users / SELECT id, / name /* display */ / FROM users / WHERE active = 1; gives SELECT id,name FROM users WHERE active = 1;
Minify drops both comment styles and collapses the whitespace.
Good to know
Formatting never changes what a query does
The formatter only changes whitespace and, if you ask, the case of keywords. It does not rewrite your logic. If a query is not valid for the dialect you chose, the formatter may fail or lay it out oddly, so pick the dialect first. Always run the result on a copy of your data if you are unsure.
When to minify
Minified SQL is smaller to embed in a string or a log line. It is harder to read and review, so keep a formatted copy in your source. This minifier removes comments, so a query that relies on an optimizer hint written as a comment, such as in MySQL or Oracle, should not be minified.
Privacy: how it works
- Your SQL is formatted by code running in this browser tab. It is not sent anywhere, and the formatter library is loaded only when you open this page.
Tips
- Pick the dialect before anything else: it decides how quoted names, functions and special operators are read.
- Format a query before a code review so the diff shows real changes instead of spacing.
- Upper-case keywords make the structure stand out; lower-case suits teams that prefer it. Pick one and keep it.
- If formatting fails, look at the first line of the error. A missing quote or bracket is the usual cause.
Frequently asked questions
Is it really free?
Yes. There is no price, no trial and no credit card. Ulkaa Tool does the work with your own device, so there is no server bill to pass on to you.
Do I need an account?
No. There is no sign-up and no login. Open the page and use it. An Ulkaa account is not needed for anything on this tool.
Does it run in my browser?
Yes. Your SQL are processed by code running in your browser tab, on your own device.
Is my data uploaded?
No. Your SQL are never sent to Ulkaa or to anyone else. You can check this yourself by watching the Network tab in your browser developer tools while you use the tool.
Which SQL dialects are supported?
Standard SQL, MySQL, MariaDB, PostgreSQL, SQLite, T-SQL for SQL Server, Oracle PL/SQL, BigQuery, Snowflake, Amazon Redshift, DuckDB, Spark, Hive, Trino, ClickHouse, IBM Db2, SingleStore, TiDB and Couchbase N1QL.
Does the formatter change my query results?
No. It changes whitespace and optionally keyword case only. Names, values and logic stay as you wrote them.
Can it format several statements at once?
Yes. Statements separated by semicolons are formatted one after another with a blank line between them.
Why do I get a parse error?
The text is not valid SQL for the chosen dialect, often because of an unclosed quote or bracket or syntax from another dialect. Try the correct dialect, or fix the first problem the message points at.
Does the minifier remove comments?
Yes, both -- line comments and /* block comments */. Text inside quoted strings and names is left as it is.
Can I run the SQL here?
This tool only formats. To run SQL on a CSV or Excel file in your browser, use the SQL on CSV tool in the same section.
Is there a size limit?
No fixed limit, but very large scripts of many thousands of lines can take a moment because formatting happens in your browser on your device.
Popular SQL Formatter pages
- MySQL FormatterBeautify MySQL queries with the MySQL dialect selected.
- PostgreSQL FormatterBeautify PostgreSQL queries, including WITH clauses and :: casts.
- SQLite FormatterBeautify SQLite scripts with several statements.
- T-SQL FormatterBeautify Microsoft SQL Server queries with the T-SQL dialect.
- BigQuery SQL FormatterBeautify GoogleSQL for BigQuery, including UNNEST and project.dataset.table paths.
- Snowflake SQL FormatterBeautify Snowflake queries, including the QUALIFY clause.
- Oracle SQL FormatterBeautify Oracle queries with the PL/SQL dialect.
- Amazon Redshift SQL FormatterBeautify Redshift queries, including LISTAGG and DATEADD.
- MariaDB SQL FormatterBeautify MariaDB queries with the MariaDB dialect selected.
- Lowercase SQL KeywordsFormat SQL with lower-case keywords and keep your names exactly as typed.
- SQL MinifierStrip comments and collapse whitespace into a compact query.