Skip to main content
Developer Tool

SQL Formatter

Make a long or minified SQL query readable, with the rules of your database: PostgreSQL, MySQL, SQL Server, Oracle, BigQuery and more.

Dialect
Indent
Keywords
Input
Result

The result will appear here

Learn more

Formatting SQL: the essentials

Queries worth reformatting

A query copied from an ORM log, an execution plan or a BI tool usually arrives on one line. Formatted, each clause (SELECT, FROM, JOIN, WHERE, GROUP BY) gets its own line and nested subqueries their own indentation, which makes a review or a pull request diff far easier to read.

Dialects and options

Pick the dialect so its syntax is understood: backtick identifiers for MySQL, [brackets] for SQL Server, :: casts for PostgreSQL, and so on. Keywords can be upper case, lower case or left as typed; indentation is 2 or 4 spaces. Formatting only changes whitespace and case, never what the query does. Large scripts are formatted off the main thread, so the page stays responsive.

How it works

SQL Formatter in 3 steps

  1. Paste your SQL

    Copy your SQL query from your editor, terminal, or log and paste it into the input field.

  2. Choose dialect & options

    Select your SQL dialect (PostgreSQL, MySQL, etc.), indentation width, and keyword casing preference.

  3. Copy the result

    The formatted SQL appears instantly in the output panel. Click the copy button to use it in your editor.

Practical guides

Get the most out of SQL formatting

How it works

SQL formatting improves readability by adding consistent indentation, line breaks, and keyword casing to your queries. Well-formatted SQL is easier to review, debug, and maintain.

This tool supports 13 SQL dialects and handles complex queries including subqueries, CTEs, JOINs, window functions and more. Large dumps are formatted in the background without freezing the page.

Quick & easy

Privacy & security

This SQL formatter runs entirely in your browser. No queries are ever sent to a server — the formatting happens locally using JavaScript.

Queries reveal table names and business rules: they are formatted in your browser and never sent.

Runs in your browser
Frequently asked questions

SQL Formatter — FAQ

Everything you need to know about our SQL formatter