Skip to content
WebKitool

SQL Formatter

Lay a query out clause by clause with keywords capitalised, so it can be read and reviewed.

Loading tool…

Processing: This tool runs entirely in your browser. Your input and any file you open stay on your device — nothing is uploaded to a server.

How to use the sql formatter

  1. Paste your SQL.
  2. Choose an indent width.
  3. Copy the formatted query.

About this tool

A query written on one line is hard to review, and reviewing queries is where the expensive mistakes get caught. This puts each major clause — SELECT, FROM, JOIN, WHERE, GROUP BY, ORDER BY — on its own line, indents the conditions under it, and capitalises keywords so the structure stands out from the identifiers.

String literals and quoted identifiers are protected before anything is rewritten, so a value like <code>'%from where%'</code> keeps its exact contents. Nothing is reordered or optimised: the formatted query is the same query, so it is safe to paste back.

Queries are never sent anywhere, which matters here more than for most formatters — a real query often contains table names, column names and literal values you would not want to hand to a third party.

Common uses

  • Making a generated query readable before reviewing it.
  • Tidying a query pulled out of application logs.
  • Formatting SQL consistently before committing it.

Frequently asked questions

Which SQL dialects work?
Formatting is keyword-based, so standard SELECT, INSERT, UPDATE and DELETE statements format well in any dialect. Vendor-specific syntax is passed through unchanged rather than broken.
Does it change my query?
Only whitespace and keyword capitalisation. String literals and quoted identifiers are protected, and no clause is ever reordered.
Is my query uploaded?
No. It stays in the page — which matters, because queries often contain real table and column names.

Related tools