SQL Formatter — Beautify SQL Queries for Any Database

Format long, messy SQL into readable queries with proper indentation and keyword casing.

0 chars
0 chars

Quick answer

To format SQL, paste your query into the KaviForge SQL Formatter and choose your database dialect (MySQL, PostgreSQL, SQL Server, Oracle, SQLite, BigQuery, and more). The query is formatted instantly with each clause on its own line, consistent indentation, and uppercase keywords.

SQL generated by ORMs, logged by databases, or written in a hurry is often a single unreadable line. Formatting puts SELECT, FROM, JOIN, WHERE, GROUP BY, and ORDER BY on their own lines so the logic is easy to follow.

Dialect-aware formatting correctly handles vendor-specific syntax such as MySQL backticks, PostgreSQL casts (::), T-SQL brackets, and BigQuery backtick-quoted table names.

How to Format a SQL Query

  1. 1Paste your SQL into the input box, or upload a .sql file.
  2. 2Select your database dialect.
  3. 3Choose keyword case (UPPERCASE, lowercase, or preserve) and indentation.
  4. 4Read the formatted query in the output box.
  5. 5Copy it or download it as formatted.sql.

Features

11 SQL Dialects

Standard SQL, MySQL, MariaDB, PostgreSQL, T-SQL, PL/SQL, SQLite, BigQuery, Snowflake, Redshift, and Spark.

Keyword Casing

Convert keywords to UPPERCASE or lowercase, or keep them as written.

Readable Layout

Clauses, joins, and conditions on separate lines with clear indentation.

Multiple Statements

Formats scripts with several queries separated by semicolons.

Helpful Errors

Reports where the formatter could not parse your SQL.

Private

Queries — including table names and data — stay in your browser.

When to Use the SQL Formatter

Read ORM-generated SQL

Format queries logged by Prisma, Hibernate, Sequelize, or Django to debug performance.

Code reviews and migrations

Consistently formatted SQL makes diffs smaller and reviews faster.

Analyze slow queries

Format queries from slow-query logs before running EXPLAIN.

Documentation and reports

Present clean SQL in wikis, runbooks, and BI dashboards.

About the SQL Formatter

Formatting uses the open-source sql-formatter library, loaded on demand, with a dedicated grammar for each dialect.

The formatter changes only whitespace and keyword case — it never alters identifiers, string literals, or query logic. Because it runs in your browser, sensitive schemas and data are not exposed.

SQL Formatter FAQs

How do I format a SQL query online?

Paste the query into the KaviForge SQL Formatter, choose your dialect, and copy the formatted result.

Which databases are supported?

Standard SQL, MySQL, MariaDB, PostgreSQL, SQL Server (T-SQL), Oracle PL/SQL, SQLite, BigQuery, Snowflake, Amazon Redshift, and Spark SQL.

How do I make SQL keywords uppercase?

Set "Keywords" to UPPERCASE. SELECT, FROM, WHERE, and all other keywords are converted automatically.

Why do I get a "Could not format SQL" error?

The query uses syntax the selected dialect does not recognise. Try the matching dialect, or check for unbalanced quotes and parentheses.

Does the formatter validate my SQL?

It parses the query to format it, but it does not check tables, columns, or whether the query will run.

Is my SQL sent to a server?

No. Formatting happens entirely in your browser.