Cubestack

SQL Formatter

Free SQL formatter and beautifier — format messy SQL queries for MySQL, PostgreSQL, SQL Server, Oracle, SQLite, BigQuery and more, with keyword case and indentation options.

SQL
Formatted SQL

Formatting only changes spacing and keyword case — the query does the same thing. Nothing is sent to a server.

What is the SQL Formatter?

A SQL formatter rewrites a query with consistent line breaks, indentation and keyword case so joins, conditions and subqueries are easy to read and review — without changing what it does.

How to use it

  1. 1

    Paste your query

    One or several.

  2. 2

    Pick the dialect

    For correct keywords.

  3. 3

    Copy or download

    As a .sql file.

Features

  • 9 dialects

    Standard SQL, MySQL, PostgreSQL, SQL Server, Oracle, SQLite, BigQuery, Snowflake, MariaDB.

  • Keyword case

    UPPERCASE, lowercase or as typed.

  • Indentation

    2 or 4 spaces.

  • Private

    Formatted in your browser.

Popular uses

  • Code reviews

    Readable queries in pull requests.

  • Debugging

    Untangle long generated SQL.

  • Learning

    See the structure of a query.

Frequently asked questions

Does formatting change the query?

No — only spacing and keyword case.

Can it fix SQL errors?

No; it formats valid SQL. Errors in syntax are reported.

Related tools