SQL Formatter
Format and beautify SQL queries with PostgreSQL, MySQL, SQLite or generic dialect and UPPER/lower/preserve keyword case. Subqueries and JOINs handled.
Loading tool controlsβ¦
Verify it yourself: press F12, open the Network tab, and use this tool β your files are never uploaded.
SQL Formatter at a glance
- Price
- Free
- Account
- Not required
- File uploads
- None β your files are never uploaded
- Category
- Developer Tools
Who uses Developer Tools?
Developers and engineers formatting JSON, testing regex, hashing data, encoding values or building API requests.
How to Use SQL Formatter
Follow these simple steps to get instant results in your browser.
Paste SQL
Paste a query β a sample with a JOIN, GROUP BY and HAVING is loaded to try first.
Pick Dialect and Case
Choose PostgreSQL, MySQL, SQLite or generic SQL, keyword case, and indent width.
Copy the Formatted SQL
Copy the result or download it as a .sql file.
What is SQL Formatter & How Does It Work?
SQL Formatter beautifies SQL queries with a real formatter library β sql-formatter, loaded on demand when you click Format, never bundled into the page. Pick PostgreSQL, MySQL, SQLite or generic SQL, choose UPPER, lower or preserved keyword case, and set the indent width.
Subqueries, JOINs, CTEs, window functions and multi-statement input are all handled with proper indentation. The sample query β a JOIN with GROUP BY, HAVING and ORDER BY β formats into readable, aligned SQL.
The formatter only reprints your query. It never connects to a database or executes anything; to run SQL against real data, use SQLite Playground on this site.
Key Features & Capabilities
Four Dialects
PostgreSQL, MySQL, SQLite and generic SQL, formatted by the sql-formatter library.
Keyword Case Control
UPPER, lower or preserve β your choice, applied consistently.
Complex Queries Handled
Subqueries, JOINs, CTEs, window functions and multiple statements.
Lazy-Loaded Library
sql-formatter loads only when you format, so the page stays light.
Private by Design
Formatting runs entirely in your browser. Your queries never leave your device.
Pro Tips
- β’Bookmark this tool for instant one-click access anytime.
- β’Drag and drop files directly onto the input surface for fastest handling.
- β’All processing happens in your browser session for maximum speed and data safety.
π― Common Use Cases
SQL Formatter - Reprint, Not Execution
The library only reprints the query with consistent indentation and keyword case β it never connects to a database or executes anything β so the same query formats identically every time for the chosen dialect.
Worked Example
- 1Sample: 271-character one-line PostgreSQL query (JOIN, GROUP BY, HAVING, ORDER BY, LIMIT 10)
- 2Formatted with keywordCase UPPER, tabWidth 2 β 20 lines, 298 characters
- 3SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY and LIMIT each start on their own line
Sources & Further Reading
- sql-formatter β sql-formatter
- SQLite Documentation β SQLite
Frequently Asked Questions about SQL Formatter
Frequently asked questions
More Developer Tools
Complementary utilities for your workflow
SQL Formatter
Format and beautify SQL for 4 dialects.