Format SQL queries for 20 dialects, including MySQL, PostgreSQL, SQL Server, Oracle and SQLite, or minify them to one line.
More:SQL CheatsheetJSON to TableFake Data GeneratorRegex Tester
Formatting uses the open-source sql-formatter library, which understands each database's syntax, so text inside quotes and comments is never changed. If a query does not format, pick your database above; vendor-specific syntax often needs the right dialect. Minifying removes comments (keeping optimizer hints like /*+ INDEX */) and extra whitespace. Everything runs in your browser; your queries are never uploaded.
Paste a query, open a .sql file or drop one in, and choose your database. Formatting understands the syntax of 20 SQL dialects, including MySQL, PostgreSQL, SQL Server (T-SQL), Oracle (PL/SQL), SQLite, MariaDB, BigQuery, Snowflake, Redshift and more, so dialect-specific keywords and quoting are handled correctly. Choose UPPERCASE, lowercase or unchanged keywords, data types and function names, an indent of 2 spaces, 4 spaces or tabs, and a standard or tabular layout. Minify mode puts the query on one line and removes comments, while keeping strings, quoted names and optimizer hints intact. If the query cannot be read, the error shows the line and column. Everything runs in your browser; your queries are never uploaded.
Standard SQL, MySQL, PostgreSQL, SQL Server, Oracle, SQLite, MariaDB, BigQuery, Snowflake, Redshift, Db2, Db2 for i, Spark, Hive, Trino/Presto, DuckDB, ClickHouse, SingleStore, TiDB and Couchbase N1QL.
It checks the query can be read for the chosen dialect and shows where it fails. It does not know your tables, so run the query on your database to confirm it works.
Some syntax only exists in one database, such as backtick names in MySQL or square brackets in SQL Server. Pick your database from the list and try again.