SQL Formatter

Turn long, messy SQL into clean, indented queries that are easy to read and review. Choose your database, keyword case and indentation. Works with SELECT, INSERT, UPDATE, CREATE and multi-statement scripts.

Your SQL

Formatted SQL

    How to use the SQL Formatter

    1. Paste your SQL, or use Try an example.
    2. Pick your database, keyword case and indent.
    3. Copy the formatted SQL or download it as a .sql file.

    Your data stays on your device. This tool runs entirely in your browser. Nothing you type or paste is sent to our server or saved. Read our privacy policy.

    Why format SQL?

    Queries copied from logs, ORMs or old code often arrive as one long line. Formatting puts each clause (SELECT, FROM, JOIN, WHERE, GROUP BY) on its own line with consistent indentation, which makes bugs easier to spot and code reviews faster.

    Before and after

    select u.name,count(o.id) from users u left join orders o on o.user_id=u.id where u.active=1 group by u.name
    SELECT
      u.name,
      COUNT(o.id)
    FROM
      users u
      LEFT JOIN orders o ON o.user_id = u.id
    WHERE
      u.active = 1
    GROUP BY
      u.name

    Choosing the dialect

    Pick your database (MySQL, PostgreSQL, SQL Server, SQLite or Oracle) so the formatter understands its special syntax, such as backtick identifiers in MySQL or :: casts in PostgreSQL.

    Upper or lower case keywords?

    SQL doesn't care, but teams do. Upper case keywords (SELECT) make the structure stand out from table and column names and are the most common style. Pick one and use it everywhere.

    Does formatting change what the query does?

    No. Only spaces, line breaks and keyword case change. Strings and identifiers are left exactly as they are. Your SQL never leaves your browser, so it's safe to format queries that contain table names or data.

    Frequently asked questions

    Does formatting change what my query does?

    No. The formatter only changes spaces, line breaks and, if you choose, the case of keywords like SELECT. Table names, values and the logic stay exactly the same.

    Which databases are supported?

    Standard SQL, MySQL and MariaDB, PostgreSQL, SQL Server (T-SQL), SQLite and Oracle PL/SQL. Choosing the right one helps with database-specific syntax such as backticks or square brackets.

    Is it safe to paste queries with real data?

    Yes. Your SQL is formatted in your browser and never sent to our server.