SQL formatter instantly formats and beautifies the SQL queries for any database. It supports MySQL, PostgreSQL, T-SQL, SQLite, BigQuery, and more.
Formatting options explained
Dialect: Controls dialect-specific syntax rules. For example, PostgreSQL supports :: casting, T-SQL uses TOP instead of LIMIT, and BigQuery uses backtick identifiers.
Keywords UPPERCASE: The most common SQL style guide convention. Makes reserved words like SELECT, FROM, and WHERE visually distinct from column and table names.
Commas before: Places commas at the start of each line (,column_name). Popular in data warehousing teams and dbt style guides - easier to comment out a column without breaking the query.
Commas after: Standard convention in most SQL editors and ORMs (column_name,).
Common use cases
Readable queries from ORMs, query builders, or database console output.
Enforce a consistent style across team SQL files before committing.
Unminify hand-written one-liners for debugging in production logs.
Format EXPLAIN queries before sharing with a teammate.
Prepare SQL snippets for documentation, blog posts, or code review.
How to Use This SQL Formatter
SQL formatter is designed for quick browser-based work when you need to format sql for 10+ database dialects. Paste or select your input in the tool area above, run the conversion or formatting step, then review the result before copying it into code, documentation, tickets, test data, or an API client.
Example input
select id,name from users where active=true order by created_at desc
Example output
SELECT id, name
FROM users
WHERE active = true
ORDER BY created_at DESC
When to Use This Tool
Make a long query readable before code review
Normalize copied SQL from logs or dashboards
Prepare database examples for docs, tickets, or migration notes
Accepted Input Formats
SQL queries from MySQL, PostgreSQL, SQLite, BigQuery, T-SQL, and similar dialects
Single statements, multi-statement scripts, and copied query logs
Minified SQL that needs consistent indentation and keyword casing
Output Details
The output keeps the same query logic while improving layout
Keyword case and indentation follow the options selected in the tool
Related Tools
JavaScript Beautifier and Formatter
Beautify or format JavaScript online instantly. Paste minified or messy JS and get clean, readable, indented code. Free JS beautifier and formatter, no sign-up.
CSS Beautifier and Formatter
Beautify, format, or prettify CSS online for free. Unminify compressed stylesheets into clean, readable code. Free CSS beautifier and formatter, no sign-up.
YAML Formatter & Validator
Format, beautify, and validate YAML online. Supports Kubernetes, Docker Compose, GitHub Actions, Ansible, and Helm. Syntax errors reported with line and column numbers.
Top comments (0)