SQL Formatter

Format SQL locally for PostgreSQL, MySQL, SQL Server and SQLite without executing queries.

File contents stay in this browser.

About this tool

Format SQL locally for PostgreSQL, MySQL, SQL Server or SQLite. Choose capitalization and indentation, remove blank lines/indentation in compact mode and compare the original and formatted lines.

Use this tool step by step

  1. Choose the SQL dialect and paste the query you want to format. Keep a copy of the original query while reviewing formatting changes.
  2. Inspect the formatted output and download it if useful. This tool does not execute SQL or establish that a query is valid, safe or efficient for your database.

How it works

A dialect-aware tokenizer and formatter organizes SQL clauses and expressions. It changes layout and selected keyword case without executing statements or contacting a database.

Example workflow

select id, name from customers where active = 1 order by name; is laid out into SELECT, FROM, WHERE and ORDER BY clauses in upper-keyword mode. Strings and comments retain their content.

Assumptions and limitations

Formatting does not prove syntax or query correctness. The library does not fully support stored procedures or custom DELIMITER directives. Compact output keeps line breaks to preserve line-comment meaning. Pasted input is limited to 262,144 characters; comparison shows at most 200 original lines.

Choose the actual database dialect before formatting. Compare outputs before using them in migration or production SQL. Never treat formatted DELETE or UPDATE statements as safer to execute.

Sources and editorial responsibility

Maintained by Renvoro Pty Ltd. Sources inform the methods and assumptions shown here; outputs have the limitations described on this page.

Guide updated 2026-11-17. Calculation method and source dates remain separate.

Method reviewed 2026-10-08. Calculation standards ยท Report an issue