离线模式
漫林
今日觉察
Free tools

Free SQL Formatter

Paste a query or open a .sql file and get it neatly indented, with colored keywords, strings and comments. Choose the dialect, keyword case, indent and comma style, or squeeze it into one line.

Open SQL Formatter →

How to format SQL

Paste your SQL

Paste a query or a whole script, or open a .sql file. Pick the dialect your database speaks.

Choose the style

Keyword case, indent, comma position and where AND/OR go. The result updates as you change them.

Copy or download

Copy the formatted SQL or save it as a .sql file. Switch to minify for a one-line version.

Manlin services

Make space for what matters

Use Manlin to reflect, plan and take your next step.

Manlin Life OS: a path from awareness to action

SQL Formatter FAQ

Which SQL dialects are supported?

Standard SQL, PostgreSQL, MySQL, MariaDB, SQLite, SQL Server (T-SQL), Oracle PL/SQL, BigQuery, Snowflake, Redshift, Spark, Hive, Trino/Presto, DuckDB, ClickHouse, Db2, Db2 for i, N1QL, SingleStore and TiDB. Picking the right one matters for quoting, comments and special operators.

Is my SQL uploaded?

No. Formatting happens in your browser, so queries with table names, customer data or credentials never leave your device.

What happens if my SQL has a mistake?

The formatter tries the whole script first. If it can’t read it, it formats each statement on its own and leaves the ones with mistakes as you wrote them, telling you the line, so one typo doesn’t block the rest.

Does formatting change what the query does?

No. Only whitespace, line breaks and, if you choose, the case of keywords, functions and data types change. Strings, quoted names and comments are kept exactly.

What does minify do?

It puts the SQL on one line, removes comments (or keeps them as /* */ if you ask) and drops spaces that aren’t needed, leaving strings untouched.

Can I put commas at the start of lines?

Yes. Choose leading commas and each list item after the first starts with a comma, which makes diffs and commenting out columns easier.

Are stored procedures supported?

Mostly. Blocks with BEGIN … END are formatted, but the formatter is built for queries and DDL; long procedural code may come out less tidy than plain queries.

More tools in this category

View all free tools →