Skip to content
๐Ÿ—„๏ธ

SQL Formatter

Developer

Format, beautify, and minify SQL queries with proper indentation and syntax highlighting. Support for all major databases.

0
0
Indent:
Formatted SQL
SELECT u.id, u.name, u.email, COUNT(o.id) AS order_count
โ”‚FROM users u LEFT
โ”‚JOIN orders o ON u.id = o.user_id
โ”‚WHERE u.status = 'active'
โ”‚AND u.created_at > '2024-01-01'
โ”‚GROUP BY u.id, u.name, u.email
โ”‚HAVING COUNT(o.id) > 5
โ”‚ORDER BY order_count DESC
โ”‚LIMIT 10
โ”‚OFFSET 0
Keywords in blueFunctions in purpleStrings in greenNumbers in orange

A query minified down to one line for an environment variable or a compact log entry and the same query formatted for a code review need opposite treatment, and getting from one to the other by hand means either manually stripping every line break or manually reintroducing indentation depending on which direction is needed. This tool does both: beautifies a cramped query into properly indented, readable SQL, or minifies a formatted query back down to a single compact line, aware of the quoting conventions that differ between databases, backticks in MySQL, double quotes in PostgreSQL, so identifiers stay correctly quoted either direction.

See more about the SQL Formatter

Useful for cleaning up a query before a code review, minifying a formatted query down for a config value or a single-line log entry, or reformatting a query pulled from a different database system without its identifier quoting breaking in the process.

Key features

  • Clean interface
  • Fast processing
  • No signup required
  • Works offline

Quick answers for SQL Formatter

What does the UPPERCASE keywords toggle do?
When checked, every recognized SQL keyword in your query, SELECT, FROM, JOIN, GROUP BY, and around 70 others, gets forced to uppercase in the formatted output, unchecking it leaves your original casing untouched.
How does the indent size setting work?
A dropdown lets you choose 2 or 4 spaces, that value controls how far each nested clause like AND, OR, JOIN, or ON is indented under the SELECT or FROM line above it.
Does the syntax highlighting distinguish more than just keywords?
Yes, keywords appear in blue, functions like COUNT and SUBSTRING in purple, quoted string literals in green, and numbers in orange, all shown live with a color key underneath the formatted output.