Skip to content
FizzKit

SQL Formatter

Indent and align SQL for readability or collapse it to one line. Control keyword, identifier, function and data-type case, indentation (spaces or tabs), expression width, tabular layouts, leading commas and AND/OR placement. Substitute ?, $1, :name and @name placeholders with real values, split multi-statement scripts, and copy the result as a JavaScript, Python, Go, Java or C# string literal. Supports PostgreSQL, MySQL, MariaDB, SQLite, SQL Server, Oracle, BigQuery, Snowflake, Redshift, DB2, Hive, Spark and Trino.

Runs locally in your browser
For long queries, open fullscreen for a wider view
Raw SQL
360 chars · 3 lines
Formatted
SELECT
  u.id,
  u.name,
  u.email,
  COUNT(o.id) AS orders,
  SUM(o.total) AS revenue
FROM
  users u
  LEFT JOIN orders o ON o.user_id = u.id
WHERE
  u.created_at >= :since
  AND u.active = TRUE
  AND u.plan IN ('pro', 'team')
GROUP BY
  u.id,
  u.name,
  u.email
HAVING
  COUNT(o.id) > :min_orders
ORDER BY
  revenue DESC
LIMIT
  50;

UPDATE users
SET
  last_seen = NOW()
WHERE
  id = :user_id;
Statements (2)
1
SELECT
  u.id,
  u.name,
  u.email,
  COUNT(o.id) AS orders,
  SUM(o.total) AS revenue
FROM
  users u
  LEFT JOIN orders o ON o.user_id = u.id
WHERE
  u.created_at >= :since
  AND u.active = TRUE
  AND u.plan IN ('pro', 'team')
GROUP BY
  u.id,
  u.name,
  u.email
HAVING
  COUNT(o.id) > :min_orders
ORDER BY
  revenue DESC
LIMIT
  50;
SELECT
2
UPDATE users
SET
  last_seen = NOW()
WHERE
  id = :user_id;
UPDATE
Input
360 B
Output
396 B
Lines
29
Statements
2
Placeholders
3
Dialect
postgresql

How to use SQL Formatter

  1. 1Paste SQL, pick the dialect and choose Format or Minify.
  2. 2Set keyword, identifier, function and data-type case and the indent (2, 4 or tabs).
  3. 3Open Options for expression width, tabular layouts, leading commas, dense operators and AND/OR placement.
  4. 4Turn on placeholder substitution and paste a JSON array or object of values to preview the final query.
  5. 5Copy the SQL, a single statement from the list, or the whole thing as a JS / Python / Go / Java / C# literal.

About SQL Formatter

Indent and align SQL for readability or collapse it to one line. Control keyword, identifier, function and data-type case, indentation (spaces or tabs), expression width, tabular layouts, leading commas and AND/OR placement. Substitute ?, $1, :name and @name placeholders with real values, split multi-statement scripts, and copy the result as a JavaScript, Python, Go, Java or C# string literal. Supports PostgreSQL, MySQL, MariaDB, SQLite, SQL Server, Oracle, BigQuery, Snowflake, Redshift, DB2, Hive, Spark and Trino.

SQL Formatter is part of FizzKit — a collection of focused developer and ad-tech tools. Because everything runs locally, it works offline once loaded and never exposes your data to a remote server.

Frequently asked questions

Standard SQL, PostgreSQL, MySQL, MariaDB, SQLite, SQL Server (T-SQL), Oracle PL/SQL, BigQuery, Snowflake, Redshift, DB2, Hive, Spark SQL and Trino/Presto.