New Tools Added! Explore What’s New

Home/Tools/SQL Formatter

SQL Formatter

Beautify and indent messy or minified SQL queries.

Formatted SQL will appear here…

Paste a minified or inconsistently formatted SQL query and get it back cleanly indented, with each clause on its own line - formatted instantly in your browser.

What is SQL Formatter?

SQL queries are frequently written or generated in a single dense line - copied from an ORM's debug log, minified for an API call, or just typed quickly without much thought for layout. That's fine for a database engine, which doesn't care about whitespace at all, but it's hard for a person to read, especially once a query has several joins, conditions, or a subquery.

Formatting a query means putting major clauses - SELECT, FROM, WHERE, JOIN, GROUP BY, ORDER BY, and so on - each on their own line, indenting column lists and conditions consistently, and generally making the query's structure visible at a glance rather than buried in a wall of text.

This tool handles the common SQL statements - SELECT, INSERT, UPDATE, DELETE - including joins and multi-condition WHERE clauses. It's a practical formatter rather than a full SQL parser, so unusually complex or vendor-specific syntax may not format perfectly in every case.

How It Works

1

Paste your SQL

Paste a minified or messy SQL query into the input box.

2

Choose formatting options

Set the indent size and whether keywords like SELECT and WHERE should be uppercase or lowercase.

3

Copy the formatted result

The formatted query updates instantly; copy it to your clipboard when you're happy with it.

Features

Clause-by-clause formatting

Major clauses like SELECT, FROM, WHERE, JOIN, and ORDER BY are each placed on their own line.

Indented column and condition lists

Column lists and multi-condition clauses are indented consistently for readability.

Keyword casing options

Choose whether SQL keywords are rendered in UPPERCASE or lowercase.

Minify option

Collapse a formatted query back down to a single compact line when you need it for a config value or API call.

Common Uses

Reading a query pulled from a log

Format a minified query copied from a slow-query log or an ORM's debug output to actually understand what it's doing.

Cleaning up a query before a code review

Format a hand-written query consistently before committing it, so reviewers can follow its structure easily.

Documenting a query

Format a query for inclusion in documentation or a wiki page where readability matters.

Preparing a query for an API payload

Minify a formatted query back down to one line for embedding in a config file or API request body.

Why Use Our SQL Formatter?

Formatting happens entirely in your browser - queries are never sent to a server, which matters since SQL often reveals details about your database schema or business logic.

Nothing pasted here is retained after you navigate away from the page.

Tips

Frequently Asked Questions