Search tools

SQL Formatter

Turn long, single-line SQL into readable queries — with dialect-aware formatting for your database.

SQL Formatter tool

Options

Processing runs in your browser.

Queries generated by ORMs, copied from logs or written in a hurry often arrive as one long line. Formatting reveals the structure — what’s being selected, how tables join, where the filters are — which makes queries easier to debug, optimise and review.

Typical uses

  • Debugging ORM output from query logs.
  • Code review of migrations and reports.
  • Performance tuning: read a slow query clearly before running EXPLAIN.
  • Documentation: paste clean queries into wikis and tickets.

A consistent style helps teams

Agreeing on uppercase keywords and one clause per line makes pull requests easier to review, because changes show up as small, clear diffs instead of one rewritten line. Format queries before committing them, and use the Diff Checker to compare two versions of a long query.

How to use the SQL Formatter

  1. Paste a query or open a .sql file.
  2. Pick your database dialect so its keywords and syntax are recognised.
  3. Choose uppercase, lowercase or original keywords, and the indent size.
  4. Copy or download the formatted SQL.

Features

  • Nine dialects: standard SQL, MySQL, MariaDB, PostgreSQL, SQLite, SQL Server, Oracle PL/SQL, BigQuery and Snowflake.
  • Each clause (SELECT, FROM, WHERE, JOIN) on its own line, with indented column lists.
  • Keyword case control.
  • Handles multiple statements, comments and string literals.

Frequently asked questions

Does the formatter check my SQL for errors?

No. It formats based on keywords and punctuation but doesn’t run or validate queries against a database. Obvious problems like unclosed quotes may produce an error.

Why choose a dialect?

Databases have their own keywords and syntax, like PostgreSQL’s :: casts, SQL Server’s square-bracket identifiers or BigQuery’s backticks. Picking the right dialect keeps them intact.

Is my query sent to a server?

No. Formatting happens in your browser, so table names, customer data in WHERE clauses and credentials stay private.

Written by