SQL formatter
Format or minify queries
No database: AIMRAN doesn't store your files, text or results
What is SQL formatter?
A long SQL query written on a single line is very hard to read. This formatter lays it out with line breaks and indentation so it makes sense at a glance, and puts keywords such as SELECT or WHERE in uppercase.
It also does the opposite: it minifies the query onto a single line, removing spaces and comments, to embed it in code.
How to use it
- Paste your SQL query or open a .sql file.
- Choose the action: “Format” or “Minify”.
- Select your database's dialect.
- Adjust the keyword case, indentation and tabular style.
- Copy or download the result.
Advantages
- 13 SQL dialects, from MySQL and PostgreSQL to BigQuery and Snowflake.
- Keywords in uppercase, lowercase or unchanged.
- Minification that respects strings and quoted identifiers.
- Free, no sign-up and no ads.
Technical details
Formatting uses the sql-formatter library with the dialects standard SQL, MySQL, MariaDB, PostgreSQL, SQLite, SQL Server (T-SQL), Oracle PL/SQL, BigQuery, Snowflake, Amazon Redshift, Spark SQL, Trino/Presto and IBM Db2. You can choose the case of keywords, data types and functions (uppercase, lowercase or unchanged), indentation of 2 or 4 spaces or tabs, and the tabular style, which aligns keywords in a left-hand column. Minification removes -- and /* */ comments (unless you choose to keep them) and extra spaces around punctuation, respecting string literals and quoted identifiers. Files up to 10 MB can be opened. It doesn't run the queries.
Frequently asked questions
How do I format a SQL query?
Paste the query, leave the action on “Format”, choose your database's dialect and copy the tidy result.
Do SQL keywords have to be uppercase?
No. SQL keywords are case-insensitive, but writing them in uppercase is a convention that improves readability.
Which SQL dialects are supported?
Standard SQL, MySQL, MariaDB, PostgreSQL, SQLite, SQL Server, Oracle PL/SQL, BigQuery, Snowflake, Redshift, Spark SQL, Trino/Presto and IBM Db2.
What is minifying SQL for?
To turn the query into one compact line, without comments or extra spaces, useful when embedding it in code or configuration files.
Does it check whether my query is correct?
It only formats. If the syntax can't be parsed it warns you, but it doesn't run the query or check tables or columns.
More Developers tools
- Base64, URL and HTML · Encode and decode in all three formats
- Hash generator · MD5 and SHA for text or files
- UUID generator · Unique identifiers instantly
- Strong passwords · With a strength meter
- JWT decoder · Read header, payload and expiry
- Regex tester · Highlighted matches and groups
- Colours and gradients · HEX, RGB, HSL, OKLCH, contrast and gradients
- CSS shadows · box-shadow with live preview