SQL Formatter

Beautify and indent SQL queries with keyword casing and one-click minify.

Format and Beautify SQL Queries

SQL arrives unformatted from ORM logs, query builders and copied snippets — often as a single enormous line. Reading a join condition or spotting a missing filter in that state is genuinely difficult, and misreading one is how production incidents start.

This formatter breaks the query onto clause boundaries, indents subqueries, and normalises keyword casing, without ever altering what the query does. String literals and comments are preserved character for character, because a formatter that changes a string is worse than no formatter at all.

Key features

  • Clause-aware line breaks — SELECT, FROM, WHERE, JOIN, GROUP BY and the rest each start a line.
  • Subquery indentation — nesting depth tracked through parentheses.
  • Keyword casing — uppercase or lowercase, applied only to actual keywords, never to your identifiers.
  • String and comment safety — quoted literals and both comment styles are passed through untouched.
  • One-click minify — collapse to a single line for embedding in code or a config file.
100% client-side — no data leaves your machine

This tool runs entirely inside your browser using native Web APIs. Your files and text are never uploaded to a server, never logged and never shared with third parties.

How to use: SQL Formatter

  1. Paste your SQL
    A single-line query from a log is the typical case, but any formatting works.
  2. Press Format
    The query is broken onto clause boundaries with subqueries indented.
  3. Set your house style
    Two or four space indentation, and uppercase or lowercase keywords.
  4. Copy it back
    Or use Minify to collapse the query to one line for embedding in application code.

Technical specifications

Processing locationEntirely in your browser — no server round trip
Data uploadedNone. Files and text never leave your device
PriceFree — no account, no trial, no usage cap
CategoryDeveloper
Works offlineYes, once the page has loaded
Browser supportChrome 90+, Edge 90+, Firefox 90+, Safari 15+
Interface languagesEnglish, 中文, हिन्दी, Español, العربية

Frequently asked questions

Does formatting change what my query does?

No. Only whitespace and keyword casing change. SQL keywords are case-insensitive, so SELECT and select are identical to the database. String literals, comments and identifiers are never touched.

Which SQL dialects are supported?

The common core shared by MySQL, PostgreSQL, SQL Server, SQLite and Oracle. Dialect-specific extensions still format sensibly because unrecognised words are passed through unchanged rather than being reinterpreted.

Why uppercase keywords?

It is the long-standing convention, and it makes the structure scannable — keywords in caps let your eye find the clause boundaries instantly when skimming a long query. Some modern style guides prefer lowercase, so both are offered.

Is my query sent anywhere?

No. Formatting happens entirely in your browser, which matters because real queries often contain table names, column names and literal values you would not want to paste into a third-party service.

Related tools

Back to all tools