Format, beautify, and indent SQL queries with customizable keyword casing and spacing.
Loading tool
About SQL Prettify
Format one or more SQL statements with consistent indentation and keyword casing. It supports dialects including PostgreSQL, MySQL, MariaDB, SQLite, SQL Server (T-SQL), Oracle PL/SQL, BigQuery, Snowflake, Redshift, Spark, Trino, DuckDB and ClickHouse. You can set keywords, data types and functions to upper case, lower case or as written, choose the indent width and a standard or tabular layout, and write dense operators. The query is only reformatted, never executed.
Common uses
- Make a long single-line query from a log or ORM readable
- Apply a consistent keyword case before code review
- Format SQL for documentation or a migration file
- Clean up queries copied from a BI tool
FAQ
- Does formatting change what my query does?
- No. Only whitespace, line breaks and the case of keywords, data types and function names change. Identifiers and string literals are left as written.
- Why should I choose the right dialect?
- Dialects differ in syntax such as identifier quoting, parameter placeholders and dialect-specific keywords. Picking the matching dialect lets the formatter recognize them instead of failing or misformatting.
- Should SQL keywords be uppercase?
- SQL keywords are case-insensitive, so it is a style choice. Uppercase keywords are a common convention because they stand out from table and column names.