Skip to content
rusthacks.dev
Databases

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.

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.

Share

Frequently asked questions

Does formatting change my query?
No. Only whitespace and, if chosen, keyword case change. Strings, identifiers and comments are left exactly as written.
Which databases does it support?
MySQL, MariaDB, PostgreSQL and SQLite syntax all format the same way, including backtick and double-quote identifiers.
Is what I paste sent anywhere?
No. The tool runs entirely in your browser with JavaScript. Nothing you type or paste is sent to our server or stored.

Go deeper

Suggested reading

Flat illustration for the post “Testing Database Code in Rust With Test Containers”, composed around deploy.
Databases

Testing Database Code in Rust With Test Containers

Run tests against a real PostgreSQL in a disposable container with the testcontainers crate. Start one per test run, migrate, isolate tests with transactions or databases, and keep CI fast with reuse.

4 min read

Keep planning

Similar tools