DevToolbox

SQL Formatter

Format and beautify SQL queries with configurable indentation.

Processed locally in your browser

SQL Input

Formatted SQL

What is the SQL Formatter?

The SQL Formatter beautifies SQL queries with consistent keyword casing, indentation, and clause alignment — turning dense one-line queries into readable, reviewable code. It supports the full breadth of common SQL: SELECT, JOIN, WHERE, GROUP BY, HAVING, ORDER BY, INSERT, UPDATE, DELETE, CREATE TABLE, CTEs, and subqueries.

Formatting is powered by the well-established sql-formatter library running entirely in your browser, with support for multiple dialects (PostgreSQL, MySQL, SQLite, BigQuery, and more) and configurable indentation. A minify mode collapses formatted queries back to a single line.

How to use the SQL Formatter

  1. Paste your SQL into the input editor (or click Example to load a sample query).
  2. Pick your SQL dialect and indentation preference.
  3. Click Format to beautify, or Minify to compress to one line.
  4. Copy the result or download it as a .sql file.

Examples

Input

select id,name from users u join orders o on o.user_id=u.id where o.total>100 order by o.total desc

Formatted

SELECT
  id,
  name
FROM
  users u
  JOIN orders o ON o.user_id = u.id
WHERE
  o.total > 100
ORDER BY
  o.total DESC

Frequently asked questions

Does formatting validate or execute my SQL?

No. The formatter restructures whitespace and casing based on SQL grammar — it doesn't connect to a database, execute anything, or guarantee the query is semantically correct.

Which SQL dialects are supported?

Standard SQL plus PostgreSQL, MySQL, MariaDB, SQLite, BigQuery, Snowflake, Spark, T-SQL (SQL Server), and PL/SQL. Pick the dialect matching your database for the best results.

Is my query sent to a server?

No. The formatting library is loaded into your browser and runs locally, so proprietary schema details in your queries stay private.

Why does my query fail to format?

Usually a syntax error — an unclosed string or parenthesis, or dialect-specific syntax that doesn't match the selected dialect. Try switching dialects or fixing the reported location.