SQL Formatter | Query Beautifier & Capitalizer

SQL Formatter

Format, indent, and capitalize SQL queries for better readability

The SQL Formatter is a browser-based tool that indents and capitalizes SQL queries for readability, recognizing standard clauses like SELECT, FROM, WHERE, JOIN, GROUP BY, and ORDER BY, with a Minify option for compacting queries back to a single line.

SQL Input

Paste SQL to format

About SQL Formatter

Paste your SQL query above and click “Format” to add proper indentation and capitalize keywords. The formatter recognizes standard SQL keywords including SELECT, FROM, WHERE, JOIN, GROUP BY, ORDER BY, and more. Use “Minify” to compress the query into a single line.

Frequently Asked Questions

How do I format a messy one-line SQL query into readable code?

Paste the SQL into the input area and click Format. The formatter adds proper indentation and uppercases standard keywords, breaking multi-clause queries onto separate lines. For example, SELECT, FROM, WHERE, and ORDER BY each start on a new line with sub-clauses indented beneath them, making complex queries far easier to read and debug.

Is my SQL query sent to a server when I use this formatter?

No. SQL formatting runs entirely in your browser. Your query, including table names, column names, and any embedded values, never leaves your device. You can safely paste queries containing sensitive data, production table names, or internal schema details without concern about server-side logging.

Does the SQL Formatter support multiple SQL dialects like MySQL, PostgreSQL, and T-SQL?

The formatter recognizes and formats standard ANSI SQL keywords. Dialect-specific syntax such as PostgreSQL’s RETURNING clause, MySQL’s LIMIT/OFFSET shorthand, or T-SQL’s TOP or NOLOCK hints may not be formatted perfectly. The formatter focuses on readability for standard DML and DQL statements; dialect-specific extensions are passed through without modification.

When would I use the Minify option for SQL?

Minifying removes whitespace and newlines to compress a query to the smallest possible string. This is useful when embedding SQL inside application code as a string literal, storing queries in configuration files with size constraints, or comparing two queries programmatically after stripping formatting differences.

What is a common gotcha when formatting SQL with this tool?

The formatter capitalizes SQL keywords based on a keyword list. If your table names or column names happen to match a reserved SQL keyword (e.g., a column called ‘name’, ‘from’, or ‘order’), the formatter may capitalize them incorrectly. Always review the formatted output before using it in production to confirm aliases and identifiers were not inadvertently altered.