Advertisement

SQL Query Beautifier & Indenter

Paste an unreadable, single-line SQL query and get it back properly indented, with uppercase keywords and each clause on its own line.

100% Free No Sign-Up Runs In Your Browser

Format your SQL query

Advertisement

Formatted Query

How to use this tool

  1. 1
    Paste your query. Any messy, single-line, or inconsistently formatted SQL works.
  2. 2
    Click "Format Query." Keywords get uppercased and each major clause — SELECT, FROM, WHERE, JOIN, and so on — gets its own line.
  3. 3
    Copy the result. Paste it straight into your editor, ticket, or documentation.

About This Tool

This formatter handles the cases that trip up simpler find-and-replace style beautifiers: string literals and comments are left completely untouched even if they contain words like "from" or "where," commas inside function calls like COUNT(a, b) stay on one line instead of breaking, and subqueries get their own indentation level automatically.

It also understands JOIN variants (INNER, LEFT, RIGHT, FULL, CROSS), GROUP BY / ORDER BY, CASE / WHEN / THEN / ELSE / END blocks, and BETWEEN...AND (so it won't wrongly break that AND onto its own line).

Frequently Asked Questions

Does this work with any SQL dialect?

It's built around standard ANSI SQL syntax common to MySQL, PostgreSQL, SQLite, and SQL Server. Highly dialect-specific syntax may not format perfectly, but standard queries work well.

Will it change my table or column names?

No — only recognized SQL keywords get uppercased. Your table names, column names, and aliases are preserved exactly as you typed them.

Does it handle subqueries?

Yes — a subquery inside parentheses gets its own indentation level, nested under the query it belongs to.

Is my query uploaded anywhere?

No. Everything runs locally in your browser. Nothing you paste is sent anywhere or saved after you close the tab.