SQL formatter and beautifier

Paste a messy query and get clean, readable SQL as you type. Each clause starts on its own line, columns and conditions line up, subqueries and CASE expressions are indented, and CREATE TABLE definitions get one column per line. Choose your dialect (MySQL, PostgreSQL, SQL Server, Oracle, SQLite or BigQuery) so backticks, [brackets], $$ strings and :: casts are handled correctly, then pick uppercase or lowercase keywords, indent size and leading or trailing commas. The tool also flags unclosed quotes, unbalanced parentheses and DELETE or UPDATE without WHERE, can minify SQL to one line, and copies the query as a Python, JavaScript, Java, C# or PHP string. Your SQL stays in your browser.

Free · No sign-up

Result
Result type

      

Paste SQL to format it.

How to use it

  1. Paste your SQL or open a .sql file.
  2. Choose the database dialect, keyword case and indent you like.
  3. Read the formatted query and fix any problems listed under it.
  4. Copy it, download it as .sql, or copy it as a code string.

Why use this tool

Readable layout

Clauses on their own lines, aligned columns and conditions, indented subqueries, CTEs and CASE.

Seven dialects

MySQL backticks and # comments, PostgreSQL $$ strings and ::, T-SQL [brackets] and GO, Oracle, SQLite, BigQuery.

Your style

UPPERCASE or lowercase keywords, 2 or 4 spaces or tabs, commas at the end or the start of lines.

Error checks

Finds unclosed quotes and comments, unbalanced parentheses and DELETE or UPDATE without WHERE.

Minify

Squeeze a query onto one line, optionally keeping comments and optimizer hints.

Copy as code

Get the query as a Python, JavaScript, Java, C# or PHP string, ready to paste.

Why format SQL?

SQL copied from logs, ORMs or BI tools often arrives as one endless line. Formatting puts each clause on its own line so you can see at a glance what is selected, which tables are joined and how rows are filtered. It makes code reviews easier, diffs in Git smaller and bugs such as a missing join condition easier to spot.

Choosing the right dialect

  • MySQL / MariaDB: `backtick` names, # comments and backslash escapes in strings.
  • PostgreSQL: $$ dollar-quoted function bodies, :: casts and $1 parameters.
  • SQL Server: [bracket] names, @variables, TOP and GO batch separators.
  • Oracle: /*+ optimizer hints */ are kept when minifying.
  • BigQuery and SQLite: backtick names and standard SQL otherwise.

Common SQL style conventions

Most teams write keywords in uppercase and names in lowercase, indent with 2 or 4 spaces and put one column per line in SELECT lists. Leading commas make it easy to comment out a column and produce cleaner diffs; trailing commas read more naturally. Whatever you choose, use it everywhere, and consider enforcing it with a linter such as SQLFluff in your CI.

Safety checks before you run a query

  • UPDATE or DELETE without WHERE changes the whole table. Run a SELECT with the same WHERE first.
  • Wrap risky changes in a transaction so you can roll back.
  • Avoid SELECT * in application code; list the columns.
  • Never paste user input into SQL strings: use parameters (?, $1, @id) instead.

Frequently asked questions

Is the SQL formatter free?

Yes. There is no sign-up and no size limit beyond what your browser handles.

Is my SQL sent to a server?

No. Formatting happens in your browser, so table names and data in your queries stay private.

Does it change what my query does?

No. Only spaces, line breaks and keyword case change. Strings, names and comments are kept exactly.

Which databases are supported?

Standard SQL plus MySQL and MariaDB, PostgreSQL, SQL Server, Oracle, SQLite and BigQuery.

Can it format stored procedures?

Yes, statement by statement. Procedural blocks are formatted as SQL; very complex PL/SQL or T-SQL control flow may need small manual touches.

Does it validate my SQL?

It catches common syntax problems such as unclosed quotes and unbalanced parentheses, but it does not check table or column names against your database.

Related tools

Need something built?

Tell us what you want to create.

Tell us what you need built, from a simple website to a complete app, AI solution, automation, or custom system.

Tell us what you want to build. We review every enquiry and reply by email.

Contact

Thanks, your enquiry is on its way.

We will review the details and reply by email.