Handitab

SQL Formatter

Format a SQL query into readable, indented lines with optional uppercase keywords, for MySQL, PostgreSQL, SQLite, or SQL Server.

About SQL Formatter

A SQL formatter lays out a query with one clause per line and consistent indentation so joins and conditions are easy to follow. This tool uses the open source sql-formatter library (version 15.3.0) with a dialect setting for standard SQL, MySQL, PostgreSQL, SQLite, or SQL Server (Transact-SQL). Keywords can be uppercased or left as typed. It changes layout only: it does not run the query or check that tables and columns exist.

Also known as: SQL Beautifier, SQL Formatter & Beautifier.

How to use SQL Formatter

  1. Type or paste into the "SQL" box, or press "Use example" to try it with sample data.
  2. Set "Dialect" and "Uppercase keywords" if the defaults do not fit.
  3. The result appears below and updates as you type.
  4. Copy the result with the copy button, or download it as a file where that is offered.

Questions about SQL Formatter

Does the dialect setting matter?

Yes, for dialect-specific syntax. Quoting styles, operators such as the PostgreSQL double colon cast, and some keywords differ between databases, and the wrong dialect can produce odd spacing or a parse error. Pick the one that matches your database.

Runs in your browser. Page last updated .

More developer tools

All 41 developer tools