SQL Formatter
Prettify and beautify your SQL queries instantly. Support for multiple dialects, custom indentation, and keyword casing. 100% client-side.
Why use a SQL Formatter?
Writing complex SQL queries often leads to messy, unreadable code, especially when dealing with multiple joins, subqueries, and long WHERE clauses. A SQL formatter restores structure by applying consistent indentation and line breaks, making it easier to:
- Identify logical errors in your queries.
- Perform peer reviews and share code with teammates.
- Maintain a clean codebase across different database systems.
How to use it
- Select your dialect. Different databases have different syntax quirks. Choose the one that matches your environment (e.g., PostgreSQL or MySQL).
- Paste your SQL. Paste your raw query into the input box. It will be formatted instantly as you type.
- Customize the output. Adjust the indentation or toggle keyword casing to match your style.
- Copy the result. Use the "Copy result" button to grab the clean SQL for your editor or database client.
Supported Dialects
This tool uses the sql-formatter library to support the most
popular SQL engines:
- Standard SQL: Great for generic ANSI SQL queries.
- MySQL & MariaDB: Handles backticks and specific functions.
- PostgreSQL: Supports double-colon casting and JSONB operators.
- T-SQL: Microsoft SQL Server dialect with square brackets.
- SQLite: Lightweight and standard-compliant.
Frequently asked questions
What does a SQL formatter do?
It re-indents your SQL queries to make them readable (prettify) or collapses them into a single line (minify). It helps in debugging complex joins and ensuring consistent code style across your team.
Which SQL dialects are supported?
Our tool supports a wide range of dialects including MySQL, PostgreSQL, SQLite, MariaDB, Transact-SQL (T-SQL), and standard SQL.
Can I change the keyword case?
Yes! You can toggle between uppercase and lowercase for SQL keywords like SELECT, FROM, and WHERE to match your preferred coding standards.
Is my SQL code sent to a server?
No. All formatting happens locally in your browser using JavaScript. Your database structure, table names, and queries never leave your device.