ToolCozy
JSON Format / DiffHOTBase64 CodecHOTURL CodecNEWTimestamp ConverterNEWUUID GeneratorHash CalculatorJWT DecoderQR Code GeneratorUnit ConverterNumber BaseData ConverterSQL FormatterIP Lookup
Image CompressHOTColor ConverterImage ConvertImage CropNEWApp Store ScreenshotNEW
Regex TesterNEWWord CounterText DiffMarkdown Preview

More Products

Playbit Games

Free online HTML5 games — play instantly in your browser

Kaola Screenshot

App Store screenshot generator with device frames & templates

Pillease

Simple pill reminder app — never miss a dose again

© 2026 ToolCozy·Privacy·Feedback

SQL Formatter

Format and beautify SQL statements, multi-dialect support

About this tool

SQL is forgiving about whitespace, which means people produce one-line monstrosities that are unreadable until formatted. A good formatter aligns keywords (SELECT, FROM, WHERE), indents subqueries and JOINs consistently, and turns 200-character lines into something humans can review.

This formatter supports multiple SQL dialects (Standard, MySQL, PostgreSQL, SQL Server, SQLite, BigQuery, etc.) so dialect-specific keywords like LIMIT vs TOP are kept on the right side. Configurable indent (2 spaces, 4 spaces, or tabs) and runs entirely in your browser.

How to use

Format SQL

  1. Paste your SQL into the input box.
  2. Pick the dialect that matches your database. The default Standard works for most ANSI-compliant queries.
  3. Choose indent style — 2 spaces, 4 spaces, or tab.
  4. Click Format. Copy the result and paste it back into your editor or migration file.

Examples

Format a JOIN

Input
select u.id,u.name,p.title from users u left join posts p on p.user_id=u.id where u.active=1 order by u.id desc limit 10;
Output
SELECT
  u.id,
  u.name,
  p.title
FROM
  users u
  LEFT JOIN posts p ON p.user_id = u.id
WHERE
  u.active = 1
ORDER BY
  u.id DESC
LIMIT
  10;
Frequently asked questions
Which dialects are supported?

Standard SQL, MySQL, PostgreSQL, SQL Server (T-SQL), SQLite, BigQuery, and a few more. The dialect mainly affects keyword recognition and a few syntax variants (e.g., MySQL backticks vs PostgreSQL double quotes for identifiers).

Will it break my SQL or change semantics?

It only changes whitespace and case of keywords (configurable). It never re-orders clauses or rewrites expressions, so the formatted SQL produces identical results. As always, test before applying to production.

Does it handle multiple statements separated by semicolons?

Yes — each statement is formatted independently. Semicolons are preserved.

What about comments?

Both -- single-line and /* multi-line */ comments are preserved in their original positions. Inline comments stay inline; standalone comments stay on their own lines.

Does it validate the SQL?

No. The formatter parses well enough to format but doesn't check whether the query is logically valid (table names exist, column types match, etc.). Run EXPLAIN in your database for that.