Developer tools · SQL
Make your SQL make sense.
Turn crowded queries into clear, consistently formatted SQL. Choose your database dialect, set the indentation, and keep working.
Read the quick guideRuns in your browser
Formatting stays on this device. Your query is not sent to TeachyLeaf.
Free online tool
SQL formatter
Paste a query or start with the example.
A small guide
Readable SQL is easier to review.
Formatting cannot fix a slow query, but it can make the structure and intent easier to see. That helps when debugging, reviewing a change, or learning how a query fits together.
Follow the shape of the query
Put major clauses on their own lines, indent selected columns and join conditions, and keep related filters together. The formatter applies a consistent layout so the query is easier to scan.
Before
select name,email from customers where active=1 order by name;
After
SELECT
name,
email
FROM customers
WHERE active = 1
ORDER BY name;
Why choose a dialect?
Database systems share much of SQL, but they also have different syntax and conventions. Selecting the dialect helps the formatter recognize the language you are writing. It does not validate table names, permissions, or whether a query is safe to run.
What this formatter does not check
This tool formats SQL in your browser; it does not connect to a database, execute queries, or guarantee that a query is valid for your server. It does not check table or column names, permissions, query results, performance, or whether a statement is safe. A formatting error can depend on the selected dialect and does not by itself prove that a database would reject the query. Review the output and test it in the intended database before use. Very large queries may take longer or use more memory depending on your device.
Input limit and privacy
The formatter accepts SQL input up to 100,000 characters to keep browser processing manageable. Formatting is performed by JavaScript on this page; the query is not sent to TeachyLeaf. Do not treat this client-side tool as a secure place to store or share confidential SQL: avoid pasting credentials or other secrets, and review the query before running it.
Quick SQL dialect reference
These common patterns show a few differences between dialects. For repeatable results when limiting rows, add an ORDER BY clause using columns that uniquely order the rows. TOP goes after SELECT; LIMIT and FETCH go after the other query clauses.
| Dialect | Return up to 5 rows | Join two text values |
|---|---|---|
| Standard SQL | FETCH FIRST 5 ROWS ONLY |
first_name || last_name |
| PostgreSQL | LIMIT 5 |
first_name || last_name |
| MySQL | LIMIT 5 |
CONCAT(first_name, last_name) |
| SQL Server | TOP (5) |
CONCAT(first_name, last_name) |
| Oracle SQL | FETCH FIRST 5 ROWS ONLY |
first_name || last_name |
The row limits are clauses, while the concatenation examples are expressions; use them in their respective positions in a query. The text examples omit a separator and assume non-NULL values; concatenation behavior with NULL differs by database. Oracle row limiting requires Oracle Database 12c or later; SQL Server's CONCAT requires SQL Server 2012 or later. Check your database version and documentation before using version-specific syntax.
A few habits that help
Practice with a complete example in SQL INNER JOIN vs LEFT JOIN, including sample data and expected results.
- Use explicit column names instead of
SELECT *when you know which fields you need. - Keep join conditions close to the join they belong to.
- Review generated SQL before running it, especially when it changes production data.
Does this tool store or upload my SQL?
No. Formatting happens in your browser with JavaScript. The query is not submitted to TeachyLeaf.
Does formatting change what a query returns?
The formatter is intended to change whitespace and keyword presentation, not query meaning. Always review the output and test queries in your own database environment.
Which SQL dialects are available?
This first version supports Standard SQL, PostgreSQL, MySQL, SQL Server, and Oracle PL/SQL. More dialects can be added as the tool grows.
Does a successful format prove that my query is valid?
No. Formatting is not database validation. Check the selected dialect, review the output, and test the query in the database version where you intend to use it.