SQL Query Beautifier & Formatter

SQL Query Beautifier & Formatter

Format SQL locally with dialect-aware indentation and keyword case. Support PostgreSQL, MySQL, SQLite, SQL Server and BigQuery.

Format a query in three steps

Paste your SQL, select its dialect and choose two or four spaces for indentation. Keep the original keyword case or convert keywords to upper or lower case. Select Format, then copy the result or download a .sql file. Load example provides a short query you can experiment with. Changing the input or an option clears the previous result so it cannot be mistaken for a new one.

SQL query formatter — VH Original
Tool illustration — VH Original

Choose the correct SQL dialect

Standard SQL, PostgreSQL, MySQL, SQLite, SQL Server and BigQuery are available. A dialect matters for quoted identifiers, operators, placeholders and special strings. For example, SQL Server commonly uses square brackets, while MySQL and BigQuery use backticks in relevant contexts. If the formatter reports a parse error, check the selected dialect before assuming your query is invalid.

What formatting changes

The formatter adds structured line breaks and consistent indentation around clauses and expressions. Its keyword setting changes recognised SQL keywords while preserving the contents of quoted string values. A query such as select id, name from users where active = true becomes easier to scan when SELECT, FROM and WHERE sit on separate lines. This tool does not rename columns or replace your query parameters.

Strings, comments and review

Words such as FROM or WHERE inside a quoted string are data, not clauses. Comments and literals need to remain meaningful after formatting. The formatter is built for syntax-aware formatting rather than simple keyword replacement. Even so, compare the output with the original before using it in a project. Formatting is not a substitute for a database test or an SQL code review.

Limits and unsupported constructs

SQL input is limited to 100,000 characters. A dialect mismatch, unfinished quote or unsupported construct can return an error. Stored procedures, custom delimiter commands and SQL mixed with template languages may need a specialist formatter or editor. The tool is not a complete SQL validator, security scanner, query optimiser or syntax repair service. It cannot determine whether tables, columns or permissions exist.

Privacy and safe workflow

SQL is formatted in your browser by a library hosted on this site. The query is not sent to an external API, stored in local storage or executed against a database. No connection string or password is needed. Ordinary website analytics are outside this tool. Keep an original copy, review the diff, run appropriate tests in your own environment and only then use the formatted query.

Advice

Keep the original input and inspect the generated result before using it in a real project.

Frequently asked questions

Does it run SQL?

No. It only formats text.

Why does valid SQL fail to format?

Check the dialect and whether the construct is supported.

Will formatting optimise a query?

No. Query planning and performance require database analysis.

Are quoted strings changed to uppercase?

The keyword setting applies to recognised keywords, not quoted string contents.

Related tools and references

Explore VH Original tools · Technical documentation