100% browser-based · zero uploads

SQL Formatter

Format and beautify SQL queries online for free — paste raw or minified SQL to instantly structure it with proper indentation, keyword casing, and clause alignment. No sign-up, no account, nothing leaves your browser.

Keywords
Indent

How It Works

1

Paste your SQL

Drop any raw, minified, or tangled SQL into the input box. Your query stays entirely in your browser — nothing is sent anywhere.

2

Pick your style

Choose keyword casing (UPPER or lower), indentation size (2 or 4 spaces), and a dialect label. The result updates instantly.

3

Copy and use

Click Copy to grab the formatted SQL. Paste it straight into your database client, code editor, or documentation.

How to Format SQL Online

  1. Paste or type your SQL query into the input panel.
  2. Select your preferred dialect label, keyword casing, and indentation. The formatted output appears immediately.
  3. Click Copy to send the result to your clipboard.

Features

  • Instant formatting: Output updates as you type — no button to press.
  • Keyword casing: Choose UPPERCASE or lowercase for all SQL keywords — identifiers always keep their original casing.
  • Configurable indentation: 2-space or 4-space indentation to match your codebase style.
  • Clause-per-line layout: SELECT, FROM, WHERE, GROUP BY, ORDER BY, HAVING, LIMIT, and UNION each start on their own line.
  • JOIN formatting: INNER JOIN, LEFT JOIN, RIGHT JOIN, and other join types each get their own line.
  • AND / OR on separate lines: Conditions in WHERE and HAVING are split across lines for easy reading.
  • Subquery indentation: Nested SELECT statements inside parentheses are automatically indented.
  • CASE expression support: WHEN, THEN, ELSE, and END are indented within CASE blocks.
  • String literal preservation: Single-quoted strings and '' escapes are never reformatted.
  • Comment preservation: Inline comments (--) and block comments (/* */) are passed through unchanged.
  • Quoted identifiers: Double-quoted, backtick, and square-bracket identifiers are preserved as-is.
  • Dialect labels: Choose Standard SQL, MySQL, PostgreSQL, SQLite, or T-SQL as a display label.
  • Your data stays private: Everything runs in your browser — nothing is uploaded, stored, or logged.
  • No account required: Open the page and start formatting straight away.
  • Works offline: Pure JavaScript — once the page has loaded, no network connection is needed.

Frequently Asked Questions

Is my SQL query uploaded to your servers?

No. All formatting happens locally in your browser using JavaScript. Your SQL never leaves your device and is never sent to or stored on any server.

Is this SQL formatter free to use?

Yes, completely free — no account, no sign-up, and no usage limits.

Which SQL dialects does the formatter support?

The formatter handles Standard SQL syntax and provides dialect labels for MySQL, PostgreSQL, SQLite, and T-SQL. Core formatting rules work across all major dialects. Dialect-specific syntax (such as :: casts in PostgreSQL or backtick identifiers in MySQL) is preserved as-is.

How does keyword casing work?

The formatter maintains a list of all standard SQL keywords. When UPPER is selected, every recognised keyword is uppercased; when lower is selected, every keyword is lowercased. Bare identifiers (table names, column names) always retain their original casing.

What SQL statements are supported?

SELECT (with JOINs, subqueries, CTEs, window functions, CASE expressions), INSERT, UPDATE, DELETE, CREATE TABLE, CREATE VIEW, ALTER TABLE, DROP TABLE, TRUNCATE, UNION, INTERSECT, EXCEPT, and more.

Does the formatter work offline?

Yes. The tool is pure client-side JavaScript — once the page has loaded, it works without an internet connection.

Does the formatter preserve string literals and comments?

Yes. Single-quoted strings (including '' escaped quotes), single-line comments (--), and block comments (/* */) are all tokenised separately and passed through to the output exactly as written.