Free tools for developers

SQL Formatter

Paste your SQL query below to format and beautify it instantly. Transforms minified or messy SQL into clean readable code.


What is SQL Formatting?

SQL formatting adds indentation, line breaks, and consistent keyword casing to make SQL queries easier to read. When you write a quick query in a database tool or receive SQL generated by an ORM it often comes out as one long line or with inconsistent capitalisation. Formatted SQL is much easier to read, debug, and review. This tool formats, beautifies, and prettifies your SQL instantly in the browser.

Well-formatted SQL also makes it easier to spot performance issues. When each clause sits on its own line you can clearly see what tables are being joined, what conditions are being applied, and what columns are being selected.

How to Format SQL

  1. Paste your messy or minified SQL into the input box on the left.
  2. Choose your indent size and keyword casing if you want to change the defaults.
  3. Click Format SQL to beautify the query instantly.
  4. Click Copy Output to copy the clean formatted SQL to your clipboard.

Format, Beautify, Prettify, and Clean SQL

These words all describe the same thing. Whether you want to beautify a SQL query, prettify a one-line statement, clean up SQL generated by an ORM, or simply indent a messy script, this tool does it. It takes SQL in any shape, including a single unbroken line, and turns it into clean readable code with each clause on its own line and consistent keyword casing throughout.

SQL Formatting Conventions

The most common convention is to write SQL keywords in uppercase and identifiers like table and column names in lowercase. Each major clause like SELECT, FROM, WHERE, JOIN, GROUP BY, and ORDER BY starts on a new line. Conditions in a WHERE clause are indented and aligned. This tool applies these conventions automatically and lets you switch keyword casing between uppercase and lowercase.

Works with MySQL, PostgreSQL, SQL Server, and Oracle

This formatter handles standard SQL syntax which covers the vast majority of statements across every major database. It works with MySQL, PostgreSQL, Microsoft SQL Server, SQLite, and Oracle. Dialect-specific syntax such as PostgreSQL dollar-quoted strings or SQL Server bracket identifiers is passed through unchanged so your query stays valid for your database after formatting.


Frequently Asked Questions

Does formatting change how the SQL runs?

No. SQL ignores whitespace between tokens. Adding line breaks and indentation has no effect on how the query executes or what results it returns. The formatted query is identical to the original as far as the database is concerned.

Which SQL dialects are supported?

This formatter works with standard SQL syntax which covers the most common statements in MySQL, PostgreSQL, SQL Server, SQLite, and Oracle. Dialect-specific syntax like PostgreSQL dollar-quoting or SQL Server bracket identifiers is passed through unchanged.

Can I format a minified one-line SQL query?

Yes. Paste a query that is all on a single line and the formatter will break it into properly indented clauses. This is one of the most common uses since SQL logged by applications and generated by ORMs usually comes out as one long line.

Can I change the indentation size?

Yes. Use the indent control to choose two spaces, four spaces, or a tab. You can also switch keyword casing between uppercase and lowercase to match your team's style.

Is my SQL safe?

Yes. Everything runs entirely in your browser. Your SQL is never sent to any server and is not stored anywhere.