SQL Formatter
SQL Formatter turns hard-to-read queries into indented SQL for developers, analysts and students. It handles up to 1 MB in your browser, without uploading your queries, but does not run or validate them.
What is the SQL Formatter?
SQL Formatter is a free tool that makes SQL queries easier to read, review and share. It uses the open source sql-formatter library to put clauses on separate lines, indent columns and subqueries, and leave a blank line between statements. Choose your database, keyword case and indentation, then format the query in your browser. Developers use it for SQL copied from application logs, analysts use it before reviewing reports, and students use it to see query structure. Only layout and keyword case change; table names, values and comments are kept. It is free, with no subscriptions.
Who it is for: SQL Formatter is for database developers, data analysts, data engineers, database administrators, students and support staff reading or sharing queries.
How to use the SQL Formatter
- Paste your query or SQL script into Your SQL.
- Choose the matching Database, such as PostgreSQL, MySQL or SQL Server (T-SQL).
- Set Keywords to UPPERCASE, lowercase or Leave as typed, then choose your Indent.
- Tap Format SQL and review the read-only Formatted SQL box.
- Tap Copy result to paste it elsewhere, or Download .sql to save a file.
Why use it
- See the query structureSeparate clauses and indented columns make long queries easier to follow.
- Choose your SQL styleSet keyword case and choose 2 spaces, 4 spaces or tabs for indentation.
- Keep queries on your deviceFormatting runs in your browser, so your queries, table names and data are never uploaded.
- Copy or download the resultUse Copy result for your editor or Download .sql to save the formatted SQL as a file.
At a glance
- What you put in
- SQL queries or multiple statements, up to 1 MB
- What you get
- Formatted SQL to copy or download as a .sql file
- Limits
- Formatting only; no execution, validation or minification
- Privacy
- Runs in your browser. Nothing you enter is uploaded or stored.
- Price
- Free for everyone. No subscriptions, no payments, no watermark.
- Works offline
- Yes, once the page has loaded
- Last checked
- by AK Shine
Worked example
select id, name from users where active = 1 order by name
SELECT id, name FROM users WHERE active = 1 ORDER BY name
Settings: Database = Standard SQL, Keywords = UPPERCASE, Indent = 2 spaces; the value 1 and all table and column names stay unchanged.
When to use something else
- Use your database's validation tools to check syntax and object names, or its execution plan to investigate performance; formatting does not run SQL or find logic mistakes.
- Some vendor-only syntax, stored procedures and unusual statements may fail with an error even with the correct Database selected; use a database-specific editor if needed.
- For SQL larger than 1 MB or for minification, use a local tool designed for that task.
Questions people ask
How do I beautify a one-line SQL query?
Paste it into Your SQL, choose Database, Keywords and Indent, then tap Format SQL. Clauses such as SELECT, FROM, WHERE and ORDER BY appear on separate lines, with columns and subqueries indented.
Which databases does the SQL formatter support?
Database offers Standard SQL, MySQL, MariaDB, PostgreSQL, SQLite, SQL Server (T-SQL), Oracle (PL/SQL), BigQuery and Snowflake. Choose the database your query targets so the formatter can handle its syntax.
Can I change keyword case and indentation?
Yes. Keywords offers UPPERCASE, lowercase and Leave as typed, while Indent offers 2 spaces, 4 spaces and Tabs. These settings control presentation, not table names or values.
Does formatting validate or fix my SQL?
No. Format SQL changes layout and keyword case; it does not check that tables exist, find logic mistakes or prove that a query will run. Use your target database's validation tools for those checks.
Does formatting change values or remove comments?
Table names, values and comments are kept; only layout and keyword case change. Review the Formatted SQL before running important queries, especially when they use unusual database-specific syntax.
Is my SQL uploaded, and can I work offline?
Your SQL is processed in your browser, and your queries, table names and data are never uploaded. Once the tool has been opened and is available offline, you can format without an internet connection.
Can I format multiple statements and save a SQL file?
Yes. Paste multiple statements into Your SQL, keeping the total input within 1 MB; the formatter leaves a blank line between statements. Use Copy result or Download .sql to keep the output.
Why does my query fail to format?
First check that Database matches the query's dialect, then tap Format SQL again. Some vendor-only syntax, stored procedures and very unusual statements may still fail with an error and need a database-specific editor.