SQL Formatter

Paste a query to instantly reformat it with consistent indentation and keyword casing.

Advertisement

Why use an online SQL formatter?

SQL pasted from a log, an ORM's debug output, or a single-line export is hard to read and easy to misread — a misplaced JOIN condition or WHERE clause can hide in a wall of text. This formatter reformats your query with one clause per line, consistent indentation, and a keyword case of your choice, so the structure is obvious at a glance.

It supports the syntax quirks of several dialects — MySQL, PostgreSQL, SQL Server, Oracle, BigQuery, Snowflake, SQLite — since formatting rules and reserved keywords differ slightly between them. Everything runs in your browser, so queries with real table or column names never leave your machine.

Frequently asked questions

Will this change what my query does?
No — only whitespace, line breaks, and keyword casing are changed. The query logic and output are identical.
Which SQL dialect should I pick?
Pick the database you're actually running the query against. Dialects mostly affect formatting of dialect-specific syntax (like T-SQL's TOP or PL/SQL blocks) — Standard SQL works fine for typical SELECT/JOIN/WHERE queries.
Does it validate my SQL?
It's a formatter, not a full SQL parser/validator — badly malformed SQL may format oddly or throw an error, but this isn't a substitute for actually running the query against your database.

Related tools