Developer · Step-by-step guide

How to Format and Beautify SQL Queries

SQL Formatter & Beautifier turns a squashed SQL query into tidy lines with clear indentation, so it is easier to read, review and debug.

Open the SQL Formatter & Beautifier Free · No sign-up · 5 steps · 2 min read

How to use it

  1. Paste your query

    Paste your SQL into Enter SQL query.

  2. Choose your database

    Pick a Dialect: MySQL, PostgreSQL, SQLite, SQL Server or Standard.

  3. Choose keyword case

    Pick UPPER (for example SELECT) or lower. You can also set the Indent.

    SQL formatter with a one-line query and PostgreSQL selected
    Your query (1), dialect (2) and keyword case (3).
  4. Press Format SQL

    Or Minify to put it on one line. Highlight Keywords adds colour.

  5. Copy or download

    The formatted query appears on the right. Press Download to save it as a file.

    Formatted SQL query split into SELECT, FROM, JOIN, WHERE and GROUP BY lines
    Format SQL (4) and the formatted result (5).

Tips and common questions

Does formatting change what my query does?

No. It only changes spaces, line breaks and keyword case. The query runs the same.

Does it check my SQL for errors?

It is a formatter, not a database, so it cannot tell you whether a table or column exists. Run the query in your database to test it.

Why choose a dialect?

Databases differ slightly, for example in how they quote names. Choosing yours keeps the output correct for it.

Privacy

Your data is processed inside your browser and is never uploaded, so it is safe to paste private or work data.

Ready to try it? The SQL Formatter & Beautifier is free and needs no account.

Open the SQL Formatter & Beautifier

See all tool guides →