Data

SQL Formatter

Format and beautify SQL queries, adjust keyword case and indentation, and work with local .sql files without executing a query or connecting to a database.

Your SQL is processed locally in your browser.

Advanced settings
0 B input0 B output0 input linesStandard SQLAuto format on
This tool formats SQL but does not execute queries or verify them against a database.
Your SQL is processed locally in your browser.

How to use it

  • Choose the SQL dialect that matches the database syntax you are working with.
  • Paste a query or open a local .sql file, then format automatically or press Format.
  • Review the output and selected dialect before copying or downloading formatted.sql.

Example

Input
select u.id,u.name,count(o.id) as orders from users u left join orders o on o.user_id=u.id where u.active=true group by u.id,u.name;
Output
SELECT
  u.id,
  u.name,
  COUNT(o.id) AS orders
FROM
  users u
  LEFT JOIN orders o ON o.user_id = u.id
WHERE
  u.active = TRUE
GROUP BY
  u.id,
  u.name;

Format SQL for readable reviews

A SQL formatter adds consistent whitespace, indentation, line breaks, and keyword casing. It helps with code review and documentation without changing where the query runs.

Choose the matching SQL dialect

PostgreSQL, MySQL, MariaDB, SQLite, Transact-SQL, BigQuery, Snowflake, PL/SQL, and generic SQL differ in quoting, operators, keywords, and functions. Select a dialect explicitly; the formatter does not guess one.

Formatting is not validation or execution

A successful formatting pass only means the formatter could process the text. It does not check tables, columns, permissions, parameter types, query plans, or behavior against a database.

Comments, strings, and placeholders

The formatter tokenizes comments, quoted strings, identifiers, and supported placeholders so they are preserved while surrounding whitespace is reorganized. Always review database-specific comments and optimizer hints.

SELECT with a JOIN

Formatting separates SELECT fields, JOIN conditions, filters, and grouping into a predictable structure, making relationships and conditions easier to inspect.

Common Table Expressions

A WITH clause can name intermediate results before the main query. The formatter indents each CTE and the query that consumes it without evaluating either statement.

Multiple statements

Semicolon-delimited statements can be formatted together with a configurable blank line between them. Stored procedures and alternate custom delimiters are outside this formatter's reliable scope.

Why minify is not included

This tool does not offer SQL minification because removing whitespace or comments safely requires dialect-aware semantic guarantees, especially around optimizer hints and procedural syntax. Formatting remains the supported operation.

Protect production data

Processing stays in the browser, but a trusted device and browser still matter. Avoid pasting credentials, personal data, or sensitive production values when placeholders can describe the query instead.

Common questions

Does this tool execute my SQL?
No. It only formats text in your browser and never connects to a database.
Does formatted SQL mean the query is valid?
No. Formatting does not verify schemas, permissions, data types, database behavior, or query safety. Validate and test the query with the intended database.
Which SQL dialects are supported?
The interface supports generic SQL, PostgreSQL, MySQL, MariaDB, SQLite, SQL Server or Transact-SQL, BigQuery, Snowflake, and Oracle PL/SQL through the sql-formatter library.
Are comments and placeholders preserved?
Supported line comments, block comments, quoted values, named parameters, and positional placeholders are tokenized and retained. Review optimizer hints and procedural SQL carefully.
Why is there no SQL minifier?
Whitespace and comments can carry dialect-specific meaning. This tool avoids claiming safe minification without stronger semantic guarantees.
Is my SQL uploaded or saved?
No. Formatting and file handling run in browser memory. Input is not placed in the URL or browser storage and disappears on reload.