I Help You

SQL Formatter

Format SQL queries with proper indentation. Free, and it runs entirely in your browser — nothing you enter is uploaded.

How to use the SQL Formatter

1. Paste your raw, compressed, or single-line SQL query into the Input panel on the left.

2. Click Format SQL — keywords are uppercased and clauses are placed on new lines with consistent indentation.

3. Review the formatted query on the right. The structure makes JOINs, subqueries, and WHERE conditions easy to read and audit.

4. Copy the formatted SQL back into your editor, documentation, or query tool.

What is it?

SQL formatters restructure query text so that each clause (SELECT, FROM, WHERE, JOIN, GROUP BY, ORDER BY) starts on its own line with consistent indentation. Keywords are uppercased by convention, and column lists and JOIN conditions are aligned for readability. This is particularly valuable when working with complex multi-join queries, deeply nested subqueries, or queries generated programmatically by ORMs.

Formatted SQL is significantly easier to debug. When a query returns unexpected results, being able to visually scan the SELECT list, trace each JOIN condition, and isolate the WHERE predicates saves considerable time. It also makes code reviews more effective — reviewers can quickly verify that indexes are being used, that JOINs are correctly typed (INNER vs LEFT vs OUTER), and that filtering logic is correct.

This tool uses the sql-formatter library, which supports standard ANSI SQL as well as MySQL, PostgreSQL, BigQuery, and Spark SQL dialects.

Example

Unformatted SQL
SELECT u.id,u.name FROM users u WHERE u.active=1 AND u.age>18 ORDER BY u.name ASC
↓
Formatted SQL
SELECT
  u.id,
  u.name
FROM
  users u
WHERE
  u.active = 1
  AND u.age > 18
ORDER BY
  u.name ASC

Benefits

Read complex JOINs and subqueries at a glance

Indented SQL makes query structure — JOIN conditions, nested subqueries, CTEs — immediately obvious without scrolling horizontally.

Share queries in PRs and tickets without walls of text

Formatted SQL is reviewable in code review comments, Jira tickets, and Slack without requiring access to a SQL editor.

Review query plans with readable SQL

Paste formatted queries into EXPLAIN ANALYZE output tools that expect well-structured SQL for plan visualisation.

Standardise query style across your team

Enforce consistent SQL indentation and keyword casing before committing queries to your repository or documentation.

Frequently asked questions

Does formatting change what the SQL query does?

No. SQL formatting only affects whitespace, indentation, and keyword casing — all of which SQL engines completely ignore. The formatted query executes identically to the original.

Which SQL dialects are supported?

The formatter handles standard ANSI SQL and is compatible with queries written for MySQL, PostgreSQL, SQLite, Microsoft SQL Server, BigQuery, and Spark SQL. Vendor-specific syntax like PostgreSQL dollar-quoted strings or MySQL backtick identifiers is preserved.

Can I use this to format stored procedures?

Yes. Multi-statement SQL including stored procedures, triggers, and CTEs (WITH clauses) is supported. Complex nested queries with subqueries and multiple JOIN levels also format correctly.

Is my query sent to a server?

No. All formatting is done locally in your browser with no network requests. Your SQL — which may contain sensitive table names, column names, or data — never leaves your device.