SQL Formatter
Format a SQL query with each clause on its own line, indented subqueries and uppercase keywords, or minify it to a single line.
Free · No sign-up · Your inputs stay in your browser
Input
Format a SQL query
Output
Formatted SQL
350 characters
A layout pass, not a parser: it never changes what the query does, and strings, quoted identifiers and comments are left exactly as written. It reads MySQL, PostgreSQL and SQLite alike.
Runs in this browser. Nothing you paste is sent to a server.
About this tool
Method, assumptions, practical next steps, and limits.
Format before you read a plan
An ORM's query log prints SQL on one line. Formatting it is the first step before running EXPLAIN, because the join order, the conditions and the subqueries become visible at a glance. Laravel's DB::listen() or ->toRawSql() (Laravel 10.15+) give you the query with its bindings filled in.
What it does not do
This is a layout pass rather than a parser, so it never changes what the query does and never rejects one. It also cannot tell you a query is wrong: check it against the database with EXPLAIN before trusting it.