2026topopentools

SQL Formatter

Paste a messy, one-line SQL query and instantly beautify it into clean, indented, readable SQL — with dialect-aware parsing and keyword casing, all in your browser.

Everything runs in your browser — your query is never uploaded to a server.

Understanding the SQL Formatter

SQL Formatter beautifies unformatted SQL queries into clean, indented, readable code. It supports 8 SQL dialects—Standard SQL, MySQL, PostgreSQL, MariaDB, SQLite, BigQuery, T-SQL (SQL Server), and PL/SQL (Oracle)—with control over keyword casing (UPPERCASE, lowercase, or preserve). Everything runs in your browser with no data sent to any server.

How it works

The tool uses the sql-formatter JavaScript library (version 15.8.2), which parses your SQL into an abstract syntax tree (AST) by recognizing keywords, operators, and structure specific to your chosen dialect. It then reconstructs the query with consistent indentation (2 spaces), line breaks, and casing rules, respecting dialect-specific syntax variations. The formatting happens entirely client-side via the Clipper API.

Worked example

Input: select u.id, u.name, count(o.id) as orders from users u left join orders o on o.user_id = u.id where u.active = true group by u.id, u.name having count(o.id) > 3 order by orders desc limit 10; Output (standard SQL, UPPERCASE keywords): SELECT u.id, u.name, COUNT(o.id) AS orders FROM users u LEFT JOIN orders o ON o.user_id = u.id WHERE u.active = true GROUP BY u.id, u.name HAVING COUNT(o.id) > 3 ORDER BY orders DESC LIMIT 10

Tips & common mistakes

  • Choose your SQL dialect first—formatting behavior differs per database (PostgreSQL array syntax, BigQuery nested structs, T-SQL CASE handling). Picking the wrong dialect may cause parse errors.
  • Keyword casing does not alter string literals or identifiers, only SQL keywords like SELECT, FROM, WHERE. Use UPPERCASE for corporate/legacy standards, lowercase for modern style guides.
  • Malformed SQL will show an error message with the parse location. Review trailing commas, unmatched parentheses, or dialect-specific syntax before retrying.
  • Use the Download button to save your formatted query as a .sql file for version control, documentation, or sharing with teammates.
  • The tool respects your input's original whitespace and comments (if the dialect supports them), only reformatting indentation and line breaks; comments are preserved.
  • Tab width is fixed at 2 spaces for consistency. If your team uses 4-space indentation, copy the output and manually adjust or use your IDE's formatter after pasting.

Related tools

Frequently Asked Questions

Which SQL dialects are supported?

You can format standard SQL plus MySQL, PostgreSQL, MariaDB, SQLite, BigQuery, T-SQL (SQL Server), and PL/SQL (Oracle). Pick the dialect that matches your database so keywords and syntax are recognized correctly.

Can it uppercase my SQL keywords?

Yes. A keyword-case option lets you force keywords like SELECT, FROM, and WHERE to UPPERCASE, lowercase, or preserve them exactly as you typed them, so your style stays consistent.

Is my SQL query sent anywhere?

No. The query is formatted entirely in your browser with JavaScript. Nothing is uploaded to a server, so even sensitive schemas and queries stay private on your device.