SQL Formatter

What is a SQL Formatter?

Prettify and format raw, minified, or unformatted SQL queries into clean readable multi-line code. Supports major SQL dialects: MySQL, PostgreSQL, SQLite, Microsoft SQL Server (T-SQL), Oracle (PL/SQL), and MariaDB with uppercase keyword formatting.

Why Use This Tool?

  • Database Query Debugging: Format long, complex SQL `SELECT`, `JOIN`, and `WHERE` clauses for easier code auditing.
  • Code Review Cleanup: Standardize SQL query formatting before submitting pull requests.
  • Dialect-Specific Syntax: Format dialect-specific keywords and backtick/quote escaping correctly.

How to Use

  1. Paste unformatted SQL query text.
  2. Select Dialect (Standard SQL, PostgreSQL, MySQL, T-SQL, SQLite).
  3. Click "Format SQL" and copy formatted query.

Real Working Example

Input:

Unformatted SQL: select u.id,u.name,o.total from users u join orders o on u.id=o.user_id where o.status='active' order by o.total desc

Output Result:

Formatted SQL:
SELECT
  u.id,
  u.name,
  o.total
FROM
  users u
  JOIN orders o ON u.id = o.user_id
WHERE
  o.status = 'active'
ORDER BY
  o.total DESC;

Important Technical Details & Specifications

  • sql-formatter AST Engine: Uses `sql-formatter` library for dialect-aware AST parsing and keyword capitalization.
  • Uppercase Keyword Toggle: Automatically converts SQL keywords (`SELECT`, `FROM`, `WHERE`, `LEFT JOIN`) to uppercase.
  • 100% Local Privacy: SQL queries stay 100% private in browser memory—never sent to remote servers.

Related Developer Tools

Frequently Asked Questions

Which SQL dialects are supported?

Supports Standard SQL, PostgreSQL, MySQL, MariaDB, SQLite, SQL Server (T-SQL), and Oracle PL/SQL.

Does it automatically uppercase SQL keywords?

Yes, keywords like SELECT, FROM, WHERE, and JOIN are capitalized automatically.

Is it free?

Yes, 100% free.

Are my private database SQL queries uploaded to a server?

No, all SQL formatting runs 100% locally in your web browser.

How does it handle subqueries and nested joins?

Subqueries and JOIN clauses are indented cleanly to show visual query hierarchy.