SQL Formatter

Format messy SQL into readable queries with proper clause breaks and keyword casing, without touching string literals.

Keyword case
SQL query

Text inside quotes and comments is never reformatted, so a keyword in a string stays exactly as you wrote it.

Formatted SQL

How to Format a SQL Query

1

Paste your query

Drop in a query of any length, whether it came out of a log file, an ORM, or a colleague's message with all the line breaks stripped out of it.

2

Choose the keyword case

Uppercase keywords are the long-standing convention and make the clause structure jump out. Lowercase suits teams whose style guide prefers it. Either way the formatting is identical.

3

Copy the result

Each major clause starts on its own line, joins and conditions are indented under it, and the select list is broken up one column per line so a long query becomes readable.

Features

Clause-aware line breaks for SELECT, FROM, WHERE, GROUP BY, ORDER BY and more
All join types recognised and placed on their own line
AND and OR conditions indented under their clause
Uppercase or lowercase keyword styling
String literals and comments left exactly as written
Works with PostgreSQL, MySQL, SQL Server and SQLite syntax
Runs entirely in your browser, queries are never uploaded
Free with no sign-up and no query length limit

Frequently Asked Questions

No. Formatting happens in your browser in JavaScript. That matters for SQL in particular, because queries often contain table names, column names and filter values you would not want to paste into a remote service.

No, and this is the thing most simple formatters get wrong. Quoted strings and comments are captured before any rewriting happens, so a value like 'FROM headquarters' stays on one line and keeps its original casing.

The formatter works on the shared syntax of PostgreSQL, MySQL, SQL Server, SQLite and most other engines. It formats layout rather than parsing a specific dialect, so vendor-specific functions pass through untouched.

No. It is a formatter, not a parser or a linter. Invalid SQL will still be laid out, so a query that looks tidy here can still fail when your database runs it.

Not currently. The tool is built for making queries readable in reviews, tickets and documentation, which is the direction people usually need.

All existing whitespace is collapsed before the query is laid out again from scratch. That is what makes the result consistent no matter how the query looked when it arrived.

WITH clauses and set operators such as UNION are recognised and placed on their own lines. Deeply nested subqueries are formatted but not indented by nesting level.

Yes, completely free with no sign-up and no limits, like every tool in the Pinkontin toolbox.

Need a Custom Tool or Application?

We build production-grade web applications, SaaS platforms, and developer tools. Let's talk about your project.

or book a free call