How-To4 min read

How to Format SQL Queries Online (Free)

SQL from ORMs, query builders, and log files is often a single unreadable line. Well-formatted SQL is dramatically easier to debug, review in code, and include in documentation. This guide shows you how to format any SQL query in seconds — with dialect awareness for MySQL, PostgreSQL, T-SQL, and more.

Step-by-Step Instructions

1

Open the SQL Formatter

Go to the SQL Formatter tool. It uses the sql-formatter library — a production-grade SQL parser that understands dialect-specific syntax.

2

Select your SQL dialect

Choose from: Standard SQL, MySQL, PostgreSQL, SQLite, T-SQL (SQL Server/Azure), PL/SQL (Oracle), BigQuery, MariaDB, and others. The formatter uses dialect-specific keyword lists to correctly handle functions, identifiers, and syntax that differ between engines.

3

Paste your SQL

Paste your raw SQL into the left panel. This can be a single SELECT statement, a complex multi-table JOIN, a CREATE TABLE definition, or a stored procedure body.

4

Click Format

Click Format. The formatter: uppercases all SQL keywords (SELECT, FROM, WHERE, JOIN, ON, GROUP BY, ORDER BY, etc.), puts each major clause on its own line, indents subqueries and nested expressions, and preserves string literals and comments.

5

Copy or download

Click Copy to copy the formatted SQL to your clipboard. Click Download to save it as a .sql file.

Why Choose a Specific SQL Dialect?

Different databases use different reserved words and functions. A formatter that doesn't know your dialect might treat a PostgreSQL-specific keyword as an identifier, producing incorrect formatting.

  • MySQL: handles backtick identifiers, LIMIT/OFFSET, and MySQL-specific functions.
  • PostgreSQL: handles double-quoted identifiers, :: cast syntax, and PG-specific types.
  • T-SQL: handles square-bracket identifiers, TOP, NOLOCK, and SQL Server-specific syntax.

Is My SQL Private?

The formatter runs entirely in your browser using the bundled sql-formatter library. Your queries — which may contain sensitive table names, column names, or data values — are never transmitted to any server.

Format your SQL now

Dialect-aware, free, browser-based.

Open SQL Formatter

Related Tools