Skip to content

SQL Formatter

Developer Toolsβ€’Client-Side & Private

Format and beautify SQL queries with PostgreSQL, MySQL, SQLite or generic dialect and UPPER/lower/preserve keyword case. Subqueries and JOINs handled.

Tool workspace

Formatting is done by the sql-formatter library, loaded only when you click Format. It handles subqueries, JOINs, CTEs, window functions and multi-statement input. Queries up to 200 KB. The formatter does not run your SQL β€” it only reprints it.

Loading tool controls…

Files processed locally β€” never uploaded to our servers
Free Instant Private

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

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.

1

Paste SQL

Paste a query β€” a sample with a JOIN, GROUP BY and HAVING is loaded to try first.

2

Pick Dialect and Case

Choose PostgreSQL, MySQL, SQLite or generic SQL, keyword case, and indent width.

3

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

Reading Inherited QueriesTurn a one-line, 400-character query from a log into indented SQL you can actually read.
Standardising a CodebaseFormat every query with the same dialect and keyword case before committing it.
Preparing SQL for ReviewPresent a query in a pull request or a document in a clean, consistent style.
Formatting a Query Copied from an ORM LogPaste the one-line query from a log, pick the dialect, and get readable SQL with each clause on its own line.
πŸ“

SQL Formatter - Reprint, Not Execution

Formula Equation:
formatted SQL = sql-formatter(input, dialect, keywordCase, tabWidth)

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

  1. 1Sample: 271-character one-line PostgreSQL query (JOIN, GROUP BY, HAVING, ORDER BY, LIMIT 10)
  2. 2Formatted with keywordCase UPPER, tabWidth 2 β†’ 20 lines, 298 characters
  3. 3SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY and LIMIT each start on their own line
πŸ“š

Sources & Further Reading

Frequently Asked Questions about SQL Formatter

Frequently asked questions

PostgreSQL, MySQL, SQLite and generic SQL. The formatter is sql-formatter, loaded on demand when you click Format β€” it is not bundled into the page.

Yes. Subqueries, JOINs, CTEs, window functions and multi-statement input are all formatted with proper indentation.

No. It only reprints the query β€” it never connects to a database or executes anything. Use SQLite Playground on this site to run queries against real data.

No. Formatting runs entirely in your browser. Your queries never leave your device.

Up to 200 KB β€” the page states the cap. The loaded sample is 271 characters and formats to 20 lines and 298 characters with PostgreSQL, UPPER keywords and a 2-space indent.

Yes β€” multi-statement input is formatted with proper indentation, and the formatter puts 2 blank lines between queries.

Complementary utilities for your workflow

View all β†’
You are here

SQL Formatter

Format and beautify SQL for 4 dialects.

Current tool
Popular

JSON Formatter

Format, beautify, and syntax-highlight JSON data.

Try tool

CSV to JSON

Convert CSV data sheets to JSON arrays.

Try tool

Text Compare

Diff two texts and highlight changes line-by-line.

Try tool

JS Minifier

Minify JavaScript with a verified byte-savings report.

Try tool