SQL Formatter
Paste messy SQL on the left — get clean, formatted SQL on the right. Formatting happens as you type.
🔒100% Client-Side. Everything runs in your browser — no data is sent to any server.
SQL input
Formatted output
Formatted SQL will appear here
Format SQL in Python with sqlparse
import sqlparse
sql = "select id, name from users where active=1 order by name"
formatted = sqlparse.format(
sql,
reindent=True,
keyword_case='upper',
identifier_case='lower',
indent_width=2,
)
print(formatted)
Common SQL style conventions
Consistent SQL formatting is essential in team settings where queries end up in version control, code review, and documentation. The most widely adopted conventions are: uppercase all SQL keywords (SELECT, FROM, WHERE, JOIN) so they stand out from identifiers; use snake_case for table and column names (user_id, created_at); place each major clause on its own line to make the logical structure obvious at a glance; and apply 2- or 4-space indentation for column lists and WHERE conditions. Many teams enforce these rules automatically with tools like sqlfluff (Python) or sql-formatter (JavaScript/Node.js) in their CI pipelines.