BYTETOOLS

SQL Formatter

Format SQL online: uppercase keywords, new lines before SELECT, FROM, WHERE and JOIN, indented AND/OR conditions. One-line minify included. Free and private.

What is the SQL Formatter?

The ByteTools SQL Formatter turns long, single-line queries into a readable layout: keywords are uppercased, each major clause — SELECT, FROM, WHERE, GROUP BY, ORDER BY, JOIN and friends — starts on its own line, columns in a select list break after each comma, and AND/OR conditions are indented beneath their clause.

  • Uppercases SQL keywords automatically
  • New line before SELECT, FROM, WHERE, JOIN, GROUP BY, ORDER BY and more
  • Indents AND/OR conditions under their clause
  • Respects quoted strings, identifiers and comments
  • One-line minify button for compact queries
  • 100% client-side — queries never leave your browser

How to use the SQL Formatter

  1. 1

    Paste your SQL query into the input box.

  2. 2

    Choose an indentation style: 2 spaces, 4 spaces or tab.

  3. 3

    Click Format SQL to beautify, or One line to collapse the query.

  4. 4

    Copy the result or download it as a .sql file.

About the SQL Formatter

The ByteTools SQL Formatter turns long, single-line queries into a readable layout: keywords are uppercased, each major clause — SELECT, FROM, WHERE, GROUP BY, ORDER BY, JOIN and friends — starts on its own line, columns in a select list break after each comma, and AND/OR conditions are indented beneath their clause.

Quoted strings, quoted identifiers and comments are recognized and preserved, so values like 'O''Brien' or column names in backticks are never altered. A One line button does the reverse, collapsing a formatted query into a compact single line for logs, ORM annotations or chat messages.

It works with the common core of MySQL, PostgreSQL, SQL Server and SQLite syntax, and runs 100% locally in your browser — your queries and the schema details inside them are never uploaded.

Frequently asked questions

How do I format a long SQL query?

Paste it into the tool and click Format SQL. The formatter uppercases keywords and starts each major clause — SELECT, FROM, WHERE, JOIN, GROUP BY, ORDER BY — on its own line with conditions indented, which makes even multi-join queries easy to scan.

Does formatting change what the query returns?

No. SQL ignores extra whitespace and is case-insensitive for keywords, so uppercasing SELECT and adding line breaks produces an equivalent query. String literals and quoted identifiers are preserved exactly, so your data comparisons are untouched.

Which SQL dialects does the formatter support?

It handles the shared core of MySQL, PostgreSQL, SQL Server and SQLite: standard clauses, single-quoted strings with '' escapes, double-quoted and backtick identifiers, [bracketed] names, and -- or /* */ comments. Highly dialect-specific constructs are passed through unmodified.

Should SQL keywords be uppercase?

Databases do not care, but most style guides recommend uppercase keywords because they visually separate the query's structure from table and column names. This formatter applies that convention automatically while leaving your identifiers exactly as typed.

Are subqueries formatted too?

Subqueries inside parentheses are kept inline on the current line, which keeps the formatter predictable. For deeply nested reporting queries you may still want to break subqueries manually after formatting.

Is my query uploaded anywhere?

No. Formatting runs entirely in your browser with JavaScript, so queries containing table names, business logic or embedded values are never transmitted or stored.

Guides for SQL Formatter

Related tools