← Back

SQL Formatter

LOCAL

Format or beautify SQL locally, with protected text values and parameters.

Format adds keyword line breaks. Beautify also normalizes spacing outside protected text.

Input

Output

What is SQL Formatter?

SQL Formatter combines the two existing formatting variants in one local tool. Format adds line breaks before its supported keywords while keeping other spacing. Beautify also normalizes spacing outside protected text and recognizes additional clauses such as HAVING and OFFSET. Both are lightweight text formatters, not database parsers or query optimizers.

How to use SQL Formatter

Paste a query, choose Format or Beautify and select Format SQL. Copy the output after reviewing it. Your input and each mode’s generated result remain available when switching modes or languages. The formatting runs in your browser; the tool does not connect to your database or execute the statement.

When is SQL Formatter useful?

Use Format when you want keyword line breaks with minimal spacing changes. Use Beautify when inconsistent indentation and repeated spaces outside protected text make a statement harder to read. These modes help with logs, tickets and code review. They do not validate table names, permissions, SQL dialects or the safety of a query.

Example

Try select 'from test' as message from users where id = :id;. Format begins with SELECT 'from test', while Beautify begins with SELECT 'from test'. The two spaces inside the text value stay intact, and the named parameter :id keeps its name. Both variants put supported clauses such as FROM and WHERE on new lines.

Practical notes

Quoted text, quoted identifiers, comments, dollar-quoted blocks and recognized named parameters are protected from keyword replacement. Ambiguous backslash-quote regions are left unchanged rather than assuming one database’s escaping rules; some code may therefore remain unformatted. Beautify normalizes ordinary whitespace only. This is not a complete SQL grammar: compare the output and use your database’s own parser and execution-plan tools for dialect-specific checks.