Skip to content
SQL → Formatted SQLDeveloper tools

SQL Query Formatter

Format SQL as you type: one column per line, joins and conditions on their own lines, subqueries indented. Strings and comments never change.

Did this tool work for you?

Used SQL Query Formatter? Share how it went to help others.

About this tool

About SQL Query Formatter

SQL Query Formatter turns a long, one-line query into one you can read. Paste the SQL and the formatted version appears as you type. Every column gets its own line, joins and their conditions are lined up, AND and OR start new lines, and subqueries, common table expressions and CREATE TABLE columns are indented. A short CASE stays on one line and a long one is split at WHEN and ELSE. Short lists such as IN (1, 2, 3) stay together. You choose how keywords look: uppercase, lowercase, or left as you wrote them. You can indent with two spaces, four spaces or a tab, and put commas at the end or at the start of the line, which some teams prefer because adding a column changes only one line. The formatter reads the query piece by piece instead of replacing words in the text, so the contents of strings, quoted names, dollar-quoted blocks and comments are never touched. The word and inside a piece of text stays as it is, and so do double spaces in it. After formatting, the result is compared with your query: if anything other than spacing or the case of keywords were different, the tool would show your original text and tell you. It understands the syntax shared by MySQL, MariaDB, PostgreSQL, SQLite and SQL Server for everyday queries, including backticks and square brackets around names, PostgreSQL casts with two colons and JSON operators, window functions, and placeholders such as $1, :name and @id. Turn on the MySQL option if your comments start with a # sign. Several statements separated by semicolons are formatted one after another with a blank line between them. Very long stored procedures are kept correct but are not indented as finely as queries. The tool only formats: it does not run the query or check that tables and columns exist. You can open a .sql file, copy the result or download it, and everything happens in your browser, so queries with customer data or internal table names are not uploaded.

SQL Query Formatter tool

When to format SQL

Readable queries are easier to fix

Queries from logs

Make a one-line query from a log readable.

ExampleA 20-column query becomes a list you can scan.

Finding a mistake

See which condition belongs to which join.

ExampleAn extra AND under a LEFT JOIN stands out.

Code review

Give every query the same shape.

ExampleUppercase keywords and two spaces in every pull request.

Documentation

Show clean SQL in a guide or ticket.

ExampleCopy the formatted query into your wiki.

Learning SQL

See the order of the clauses.

ExampleSELECT, FROM, WHERE, GROUP BY and ORDER BY each start a line.

Migrations

Read a generated CREATE TABLE.

ExampleOne column per line with its type and constraints.

SQL formatting tips

Small habits that help

Pick one style

Agree on keyword case and comma position in your team and keep to it.

Formatted is not correct

Formatting does not check tables, columns or logic. Run the query on test data.

Check the brackets

If the indentation looks wrong near the end, a bracket is probably missing.

Need it small instead?

The SQL minifier removes comments and spaces.

Open SQL Minifier

JSON in a column?

Format the value on its own.

Open JSON Formatter

Leading commas

With commas at the start of the line you can comment out any column but the first.

Built & tested by

HemantInsights

Senior Software Engineer · Developer of Toolyconvert

Hemant developed SQL Query Formatter and tests it on desktop and mobile with real files. He is a senior software engineer from Dehradun, India, building websites since 2014, and designed and developed Toolyconvert end to end.

Last updated 24 November 2026

Answers and guidanceFrequently Asked Questions
Does it run my query?
No. It only changes spacing and, if you choose, the case of keywords.
Which databases does it support?
Everyday queries for MySQL, MariaDB, PostgreSQL, SQLite and SQL Server. Procedural code is kept correct but is formatted more simply.
Will it change text inside quotes?
No. Strings, quoted names and comments are kept exactly as they are.
Can I keep keywords in lowercase?
Yes. Choose lowercase, or “As written” to leave them alone.
Why is my text shown unchanged?
It could not be formatted safely. A quote or bracket is usually not closed.
Can I format several statements?
Yes. Separate them with semicolons.
Is my SQL uploaded?
No. It is formatted in your browser.
More tools for your workflowRelated Tools

Featured on

Toolyconvert is listed on these product directories and launch platforms.