SQL Formatter

Format SQL queries with clear keyword capitalization and indent linebreaks. Fast, free, and fully client-side.

Input source
Formatted output

How the SQL Formatter Works

Starts a new line before major SQL clauses such as SELECT, FROM, WHERE, JOIN, GROUP BY, HAVING, ORDER BY, and LIMIT, and before AND and OR. Keywords are matched as whole words regardless of case. The tool does not change keyword case or indentation and does not check the query syntax. Runs in your browser and the query is never uploaded.

Usage Example

Lays out a reporting query with several joins so each clause can be read on its own line before review.

Frequently Asked Questions

Does it change keyword capitalization?

No. Keywords are matched regardless of case, but their original capitalization is left alone. Uppercase and lowercase keywords stay the way you typed them.

Are string literals and comments protected?

No. Line breaks are inserted before any matching keyword, so a word such as WHERE inside a quoted string or comment can also start a new line. Review those spots after formatting.

Does it check whether the query is valid?

No. The output is the same query with different spacing. A misspelled table name is left unchanged and no error is reported, so run the query in your database to confirm it works.

Browse more

See all syntax formatters and converters.