DataHub Tools SQL Formatter

SQL Formatter

Local-first

Format common SQL SELECT, INSERT, UPDATE, and WHERE clauses for quick reading.

How this tool actually works

The tool loads sql-formatter 15.8.2 locally and formats the input with generic SQL rules, uppercase keywords, and two-space indentation. Token-aware formatting prevents the old regular-expression corruption of strings and comments, but it does not validate database semantics.

  • Use token-aware SQL formatting
  • Preserve quoted strings and comments
  • Apply uppercase keywords and two-space indentation

How to use it

  1. Paste a SQL statement and keep a copy of the original.
  2. Format it with the generic SQL dialect.
  3. Review vendor-specific syntax and placeholders in a dialect-aware editor.
  4. Run database validation or tests before executing changed SQL.

Quick example

Example input

SELECT id, note FROM jobs WHERE note='research and development' AND active=true;

Expected result

The WHERE clause is formatted while 'research and development' remains unchanged.

Formatting is token-aware but uses generic SQL rules; vendor-specific grammar, templates, and database semantics still require review.

Best use cases

  • Make SQL easier to review.
  • Normalize formatting in documentation examples.
  • Prepare generic SQL before dialect-specific validation.

References and scope

sql-formatter tokenizes input for formatting, while database documentation remains authoritative for dialect grammar and execution semantics.

Sources checked July 24, 2026. Specifications and platform behavior can change; verify the sources before formal use.

Known limitations

  • The current page uses fixed uppercase keywords and two-space indentation.
  • The formatter does not connect to or execute against a database.
  • PostgreSQL, MySQL, SQLite, and other dialects can still require different formatting rules.

FAQ

Which formatter is used?

The page loads sql-formatter 15.8.2 locally in the browser.

Are quoted strings preserved?

The token-aware formatter keeps string and comment tokens separate from SQL keywords.

Does it validate SQL?

No. Formatting does not prove database syntax or semantics.

Which dialect is used?

The current page uses generic SQL formatting; review vendor-specific statements separately.