What does a SQL formatter do?
You paste a long, unformatted SQL query. You get a clean, readable query with indentation, uppercase keywords, and a sensible column layout. Same idea as Prettier for JavaScript, but for SQL.
You pick the dialect (PostgreSQL, MySQL, SQLite, MSSQL, BigQuery, MariaDB, Oracle), because each database has its own keywords and small syntax quirks. You can set keyword case (UPPER vs lower), comma position (after each column, or at the start of the next line), and indent width.
The Minify mode does the opposite: strips comments and folds everything into one line. Handy when you paste a query into a log or a string literal in code.
How to use it
- Paste your SQL query into the left panel. It can be one line, no indentation, mixed case, anything.
- Pick the dialect of your database from the dropdown. For PostgreSQL pick PostgreSQL, for MySQL/MariaDB pick the matching variant.
- Choose keyword case: `UPPER` (classic), `lower` (popular with modern teams), or `preserve` (leave as-is).
- Choose comma position: `after` (comma at end of line, classic) or `before` (at the start of the next line, easier to add/remove columns without breaking diffs).
- Copy the result with the Copy button. Paste into your IDE, migration tool, or documentation.
- The Minify mode collapses the query to a single line. Use it when you want to paste SQL into a string literal in code, or into a one-line log.
When this is useful
Typical situations where a SQL formatter saves time:
- Code review where a coworker pasted a query in one line. Paste it here, format it, read it calmly.
- Database migration with dozens of CREATE TABLE and ALTER statements. After formatting, the file is ready for a clean PR.
- Debugging ORM queries (Prisma, TypeORM, Drizzle). ORMs emit SQL in one long line. The formatter shows what actually hit the database.
- Technical documentation, reports, presentations. Formatted SQL looks professional.
- Porting SQL between dialects. First format in one dialect, then use our SQL dialect converter to swap AUTO_INCREMENT for SERIAL and similar differences.
- Minify for logs or for string literals in code: one long line, no comments, ready to paste into `db.query('...')` in Node.js or Python.
Got a CREATE TABLE and want a Prisma or Drizzle schema? Use our SQL to ORM converter. Working with DBML (Database Markup Language)? See DBML to SQL.