SQL Formatter — Prettify Ugly Queries
Paste a SQL query (the kind that comes out of an ORM as one giant unreadable line) and MiniMax Converter formats it with proper indentation, keyword capitalisation, and line breaks at logical boundaries. Supports PostgreSQL, MySQL, SQL Server, SQLite, BigQuery, Snowflake — pick the dialect to get the right syntax highlighting and keyword set.
What gets formatted
Keywords (SELECT, FROM, WHERE, JOIN, etc.) capitalised consistently. Each clause on its own line. JOINs aligned. Subqueries indented. Long WHERE conditions broken across lines. Comments preserved (both -- single-line and /* ... */ block). The output is functionally identical SQL — just readable.
How to use it
- Open Tools → Convert & Format → SQL formatter.
- Paste your SQL.
- Pick a dialect (matters for which words are reserved keywords).
- Pick formatting options: keyword case (UPPER / lower / Title), comma position (trailing / leading), max line width.
- Output appears in the bottom panel. Copy back to your code.
Why ORM-generated SQL is hard to read
ORMs (SQLAlchemy, Hibernate, Entity Framework, Django ORM) typically print SQL as one long line for compactness. Combined with auto-aliased table names (t1, t2, t3) and computed JOIN orders, the output is genuinely hard to follow. Formatting it is the first step in debugging slow queries.
Questions and answers
Does it execute the SQL?
No — pure text transformation. Safe for queries against production schemas (the tool never connects to a database).
How big a query can it handle?
Hundreds of thousands of characters — even crazy ORM output formats fine. Beyond that, formatting itself becomes slow.
Will it fix bugs in my SQL?
No — it preserves the query exactly, just reformats. If your query has syntax errors, the formatter typically still works (it's lenient) but doesn't fix them.
What about stored procedures / functions / triggers?
Multi-statement scripts work — each statement formats independently. Procedural bodies (PL/pgSQL, T-SQL procedures) get basic formatting but procedural languages have their own quirks the tool may not handle perfectly.
Related tools
Get MiniMax Converter
Cross-platform desktop app. Linux free for non-commercial use; Windows & macOS one-time €20 license. No subscription, no telemetry, no account.