SQL Formatter

Use the sql formatter tool online for quick developer workflows. Add examples, caveats, and avoid pasting sensitive secrets.

Free online file converter tool. Works in Chrome Firefox Safari Edge Opera and other modern browsers on Windows macOS Linux Android and iOS. No software installation required. Browser-side processing keeps your file local when supported. Completely free to use with no account needed.

SQL Formatter

Format and beautify SQL queries with proper indentation and keyword capitalization.

SQL Formatter Features

Clean, readable SQL formatting for any dialect.

Keyword Capitalization

SQL keywords formatted in uppercase.

Smart Indentation

Subqueries and clauses properly indented.

Multi-Dialect

Works with MySQL, PostgreSQL, SQLite, SQL Server.

How to Format a SQL Query

  1. Paste your SQL into the input box

    Drop a single statement or a batch of statements into the SQL Input field. The formatter runs entirely in your browser, so the query you paste stays on your device and is never sent to a server.

  2. Set the indent size and keyword case

    Pick a 2-space or 4-space indent for continuation lines, and toggle Uppercase Keywords on to render words like SELECT and JOIN in capitals or off to lower-case them. Choose a dialect label to match the query you are working with.

  3. Click Format SQL and copy the result

    Press Format SQL to put each clause on its own line with consistent indentation. Use Copy Result to send the output to your clipboard, or Clear to empty both boxes and start again.

What the Formatter Changes and What It Leaves Alone

This is a layout and keyword-case formatter, not a parser or validator. It rewrites spacing and capitalization so a query is easier to read, but it does not change the meaning of your SQL or check whether it will run. The table below shows what each option controls.

BehaviorWhat it doesWhat it does not do
Clause line breaksPuts SELECT, FROM, WHERE, JOIN, GROUP BY, ORDER BY and similar clause starters on their own linesDoes not reorder or rewrite clauses
IndentationIndents non-clause continuation lines by your chosen 2 or 4 spacesDoes not track multi-level subquery nesting depth
Keyword caseCapitalizes or lower-cases recognized SQL keywords based on the Uppercase toggleDoes not change table, column, or alias names
WhitespaceTrims input, converts tabs to spaces, and normalizes blank runsDoes not collapse a query into a single minified line
Dialect labelLets you tag the query as Generic, MySQL, PostgreSQL, or SQLiteDoes not apply dialect-specific parsing or syntax rules
ValidationReformats whatever text you provideDoes not check syntax or report SQL errors

When This Formatter Is the Right Tool

Cleaning up pasted queries

Ideal when you copy a one-line query from a log, ticket, or chat message and want each clause broken out and indented so you can read it quickly.

Standardizing keyword case

Use it to make keywords consistently uppercase or lowercase across a query before saving it to a repository or pasting it into a code review.

Working with sensitive queries

Because formatting happens locally in your browser, this is a good fit when you prefer not to paste internal queries into a tool that uploads them. Still avoid pasting real passwords or secrets.

When you need parsing or validation instead

If you need true syntax checking, dialect-aware parsing, or deeply nested subquery alignment, run the query against your database engine or a dedicated SQL parser rather than this layout formatter.

Common Problems and Fixes

Nothing happens when I click Format

The output stays empty if the input is blank or only whitespace. Paste an actual query into the SQL Input box, then click Format SQL again.

Subqueries are not indented level by level

The formatter applies a single indent step to continuation lines rather than tracking nesting depth, so deeply nested subqueries land at the same indent. For complex nesting, adjust the inner lines by hand after formatting.

A word I expected was not capitalized

Only recognized SQL keywords are re-cased. Function names, data types, table names, and column names are left untouched on purpose, so they keep whatever case you typed.

Switching dialects changes nothing

The dialect selector labels your query but does not alter the formatting logic, which is shared across all dialects. The layout and keyword casing you see will be the same whichever dialect you pick.

References

  1. ISO/IEC 9075: SQL standard - ISO
  2. SQL - overview
  3. Pretty-printing - overview
  4. SQL syntax - PostgreSQL
  5. SQL statements - MySQL
  6. SELECT statement - overview
  7. Clipboard.writeText() - MDN Web Docs, Mozilla
  8. Blob - MDN Web Docs, Mozilla