Loading tool...
Search for a command to run...
Format and beautify SQL queries with configurable settings
About these settings:
Files never leave your device
Not available — would need cloud processing
Running SQL queries and optimization analysis require a database engine on the server.
SQL formatting is the practice of applying consistent indentation, line breaks, and keyword capitalization to database queries so they are easier to read, review, and maintain. A single-line query like select u.id,u.name,o.total from users u join orders o on u.id=o.user_id where o.total>100 and u.active=1 is technically valid, but it hides the logical structure of the statement. In production codebases where queries grow to dozens of lines with nested subqueries, CTEs, and multiple JOIN clauses, unformatted SQL becomes a serious liability during debugging and code review. Proper formatting surfaces the relationships between tables, makes WHERE conditions scannable at a glance, and ensures that every developer on a team reads the same visual structure. Capitalizing reserved keywords like SELECT, FROM, WHERE, and JOIN is the most widely adopted convention because it visually separates SQL syntax from user-defined table and column names. This tool formats your queries entirely in the browser using the sql-formatter library -- your SQL never leaves your machine.
The most frequent use case is code review preparation. Before opening a pull request that includes migration files or repository queries, running them through a formatter guarantees reviewers can focus on logic instead of style. Another common scenario is debugging complex joins. When a query returns unexpected results, reformatting it often reveals a misplaced ON condition or an accidental cross join that was invisible in a single compressed line.
Teams migrating queries between database engines -- for example, moving from MySQL to PostgreSQL -- benefit from formatting because dialect-specific syntax differences (backtick quoting vs. double-quote quoting, LIMIT/OFFSET placement) become obvious once each clause sits on its own line. ORM-generated SQL is another prime candidate: tools like Sequelize, Hibernate, and Django ORM emit machine-optimized queries that are nearly unreadable to humans. Pasting that output here and selecting the correct dialect instantly turns it into something you can reason about.
Beyond day-to-day development, formatted SQL is essential for technical documentation. Whether you are writing an internal wiki page explaining a reporting query, preparing slides for a database architecture review, or publishing a blog post about query optimization, well-formatted SQL communicates intent far more clearly than a raw dump from your application logs.
Uppercase keywords are the de facto standard in most style guides, including those from Oracle and Microsoft. Capitalizing SELECT, FROM, JOIN, WHERE, GROUP BY, and ORDER BY creates an immediate visual hierarchy that separates SQL structure from data references. For indentation, two or four spaces both work well -- the key is consistency across your project. Nested subqueries should receive an additional level of indent so the nesting depth is obvious:
SELECT
u.name,
u.email,
(
SELECT COUNT(*)
FROM orders o
WHERE o.user_id = u.id
AND o.status = 'completed'
) AS completed_orders
FROM users u
WHERE u.active = 1
ORDER BY u.name ASC;Notice how each JOIN clause aligns with FROM, and compound WHERE conditions break onto separate lines with the boolean operator (AND / OR) leading the new line rather than trailing the previous one. This "leading comma" or "leading operator" style makes it trivial to comment out a single condition during debugging. Meaningful table aliases (u for users, o for orders) keep lines short without sacrificing clarity, while single-letter aliases on unrelated tables should be avoided. Finally, adding a brief comment above non-obvious logic -- -- Exclude soft-deleted accounts -- saves future readers from reverse-engineering your intent. Consistently applying these practices reduces bugs: studies from Stripe and GitHub engineering teams have shown that readable SQL catches logic errors during review that would otherwise reach production.
Transform messy, single-line SQL queries into beautifully indented and readable code.
Supports MySQL, PostgreSQL, SQL Server, MariaDB, Oracle, SQLite, and more.
Automatically convert SQL keywords to uppercase for consistent styling.
Full syntax highlighting for SQL queries to help identify structure and errors.
Your database queries are never sent to any server. All formatting happens in your browser.
Quickly copy your formatted SQL to use in your IDE or database manager.
Paste SQL Paste your raw or messy SQL query into the editor.
Select Dialect Choose the SQL flavor (e.g., MySQL, PostgreSQL) from the settings.
Click Format Click the 'Format SQL' button to beautify your query.
Copy Result Copy the formatted SQL to your clipboard.
Format and beautify SQL queries with support for 10+ dialects (MySQL, PostgreSQL, SQLite, etc.). Configurable indentation, uppercase keywords, and dense operators. 100% client-side - your queries never leave your browser.
| Feature | JumpTools | SQLFormat.org | CodeBeautify |
|---|---|---|---|
| Price | Free | Free | Free (ads) |
| Privacy | 100% client-side | Server-side | Server-side |
| SQL dialects | 10+ (MySQL, PostgreSQL, etc.) | Standard SQL | Standard SQL |
| Syntax validation | Yes | Limited | Yes |
| Keyword case options | Upper/preserve | Upper/lower | Upper only |
| Indentation options | 2/4 spaces, tabs | 2/4 spaces | Fixed |
| File upload | Yes (.sql) | No | Yes |
| Undo/redo | Full history | No | No |