Free · No sign-up · Runs in browser

SQL Formatter

Pretty-print any SQL query — SELECT, INSERT, UPDATE, DELETE, DDL — with configurable indentation and uppercase keywords. Works for Postgres, MySQL, SQLite, and MSSQL. 100% client-side.

SQL Input
Formatted SQL
// Formatted SQL will appear here…

About the SQL Formatter

This free online SQL formatter pretty-prints any SQL query so you can read it, review it in a pull request, or paste it into documentation. It breaks major clauses (FROM, WHERE, GROUP BY, ORDER BY, JOIN…) onto their own lines, aligns column lists, and optionally uppercases keywords. Works with Postgres, MySQL, MariaDB, SQLite, and MSSQL dialects.

Why Readable SQL Matters

A production query often lives longer than the ticket that produced it. Formatting makes it easy to spot missing joins, forgotten WHERE clauses, wrong column aliases, and off-by-one LIMITs. Reviewers can see the shape of the query in one glance instead of chasing it through one unwrapped line.

Common Use Cases

  • Reformat ad-hoc queries pasted from Slack or chat
  • Normalize SQL in migration scripts before committing
  • Clean up ORM-generated queries (Hibernate, Prisma, Sequelize) for debugging
  • Prepare SQL for documentation and runbooks
  • Review DBA scripts and stored procedures

Formatting Rules

  • Each major clause starts on a new line
  • Column lists in SELECT get one line per column
  • AND and OR are indented under WHERE
  • JOIN … ON … stays on two lines for clarity
  • Comments (-- … and /* … */) are preserved

Frequently Asked Questions

Does it support stored procedures and PL/pgSQL?

Partially — the formatter is clause-aware rather than a full dialect parser, so complex procedural blocks keep their internals mostly intact. For heavy procedural code, run it through your IDE's dialect-specific formatter instead.

Is my SQL sent to a server?

No. The query is parsed and rewritten entirely in your browser — safe for queries that reference internal table names or confidential column structures.

Does it validate my SQL?

No — formatting is syntax-agnostic by design. A query that doesn't execute will still format. For validation, run the query against an actual database or use your dialect's EXPLAIN output.

Related Tools and Guides

Convert JSON data to PostgreSQL INSERT statements, or generate a Prisma schema from JSON. Read the SQL formatting guide for deeper conventions.

Dialect-friendly

Postgres, MySQL, SQLite, MSSQL — same formatter, same output.

Readable layout

Clause-per-line output and indented AND/OR so reviews actually read.

Fully private

Queries stay in your browser — never sent to a server.