Skip to content

SQL Formatter

Pretty-print SQL with consistent keyword casing and line breaks.

Runs in your browser

Paste any SQL query - SELECT, INSERT, UPDATE, DELETE, WITH. We break before each top-level keyword (FROM, WHERE, JOIN, GROUP BY, ...) and align SELECT columns one per line. Pick a keyword case and copy the result.

How to use it

  1. Paste your SQL

    Any common dialect. Sample loaded by default.

  2. Pick a keyword case

    UPPER, lower or Preserve. UPPER is most common in code reviews.

  3. Copy the result

    Formatted output appears in the right pane. Copy button next to the heading.

What is it?

A SQL formatter takes a one-line, hand-written or auto-generated query and produces readable, multi-line SQL with consistent indentation and keyword casing. Standard housekeeping before code review, before committing a migration, or before sharing a query in chat.

When to use it

Reading a one-liner from a log, cleaning up a generated query from an ORM, preparing SQL to paste in a Slack thread, or refactoring a slow query - the formatted form is easier to follow when you're staring at a WHERE clause for the third time.

Common mistakes

Treating the output as a parsed/validated query - it isn't validated. Database dialect quirks (PL/pgSQL, T-SQL, MySQL backticks) may format oddly. And don't rely on the formatter for security: it does not escape user input.

FAQ

Is this a real SQL parser?
No. It's a lightweight tokeniser that recognises common keywords and breaks lines around them. Works for typical queries; won't reformat exotic edge cases perfectly.

More in this category