SQL Formatter

Format and indent common SQL queries locally in your browser while preserving string literals and comments.

Ready. Paste a SQL statement and click "Format SQL".

About the Lightweight SQL Formatter

This formatter uses a browser-local lexical tokenizer to indent standard SQL clauses (WITH, SELECT, FROM, JOIN, WHERE, AND/OR, GROUP BY, HAVING, ORDER BY, LIMIT, INSERT INTO, UPDATE, DELETE FROM, and UNION) while protecting single-quoted strings, double-quoted identifiers, backticks, and comments (-- and /* ... */).

Scope Note: This is a lightweight, dialect-neutral formatter that executes 100% locally in your browser rather than a full AST parser for vendor-specific procedural extensions (such as PL/pgSQL or T-SQL stored procedures).