AZ Tools

SQL Formatter

Developer

Paste any SQL — a one-liner from a log, a hand-written query, or a stack-traced procedure — and see it pretty-printed with consistent indentation, keyword casing, and lines between statements. Pick the SQL dialect for accurate handling of dialect-specific syntax (window functions, returning clauses, dialect keywords). The formatter runs entirely in your browser; no SQL leaves the page.

Formatted
SELECT
  u.id,
  u.name,
  count(o.id) AS order_count
FROM
  users u
  LEFT JOIN orders o ON o.user_id = u.id
WHERE
  u.created_at > '2026-01-01'
GROUP BY
  u.id,
  u.name
HAVING
  count(o.id) > 5
ORDER BY
  order_count DESC
LIMIT
  10;

How to use

  1. Paste the SQL into the input.
  2. Pick the dialect (default Standard SQL works for most queries).
  3. Choose keyword case and indent width.
  4. Copy the formatted output.

Frequently asked questions

Which dialects are supported?
Standard SQL, PostgreSQL, MySQL, SQLite, MariaDB, T-SQL (SQL Server), BigQuery, Snowflake, Redshift, and Spark SQL — provided by the sql-formatter library.
Does it execute the query?
No — it only reformats text. The query is never run, parsed against a real database, or sent anywhere.
Will it break on syntax errors?
It's resilient — the formatter does its best on partially valid SQL and shows an error message only when the input can't be tokenized at all.
Why are comments preserved oddly?
SQL comments don't have a strict canonical position. The formatter keeps them attached to the nearest token, which sometimes shifts indentation a little.

Related tools