Skip to content

SQL formatter. Readable in one keystroke.

Your SQL never leaves your browser. Nothing is uploaded.

Output Waiting for input…
Formatted SQL appears here…

Formatting is lenient, it pretty-prints what you paste rather than fully validating syntax. Minify collapses each statement to a compact single line. Changing any option above re-formats automatically.

Readable SQL, without a paste-into-a-website round trip

Messy SQL is hard to review and harder to trust. This formatter beautifies queries with consistent indentation and keyword casing so joins, filters and aggregates read at a glance, or minifies them to a single compact line when you need to inline a statement. It understands 13 dialects (MySQL, PostgreSQL, SQL Server, BigQuery, Snowflake, Redshift, SQLite, Spark, Trino, Db2, Oracle PL/SQL and Standard SQL), and the whole engine runs in your browser, paste production queries here without a single byte leaving your machine. No account, no upload, free forever.

§ · written guide

How to use the SQL Formatter

This formatter rewrites a SQL query with consistent line breaks, indentation and keyword case so it is easier to read and review, or squeezes it onto one line. It uses the open source sql-formatter library, which knows the syntax of 13 dialects. It is for developers and analysts tidying queries before a code review, a ticket or documentation.

Step by step

  1. Paste your SQL

    Paste one or more statements into Input SQL. The page opens with a sample SELECT and INSERT already formatted, and Load sample brings them back. The small counter above the box shows the number of lines and the size of what you pasted.

  2. Pick the dialect

    Choose your database under Dialect, from Standard SQL to MySQL, PostgreSQL, SQL Server (T-SQL), BigQuery, Snowflake or Oracle PL/SQL. The dialect tells the formatter which keywords, quote styles and operators to expect.

  3. Set the layout

    Choose Indent as 2 spaces, 4 spaces or Tab, Keyword case as UPPERCASE, lowercase or Preserve, and Blank lines between queries as 1, 2 or 0. The defaults are 2 spaces, UPPERCASE and 1.

  4. Format or minify

    Press Format to lay the query out across lines, or Minify to put everything on one line. Typing in the input does not update the output on its own; press Format again after you edit. Changing an option above re-formats the output straight away.

  5. Copy or download

    Press Copy to put the output on your clipboard, or Download .sql to save it as formatted.sql. Clear empties both panes.

Reading the result

  • After Format, the status next to Output shows the line count. The sample comes out as 25 lines, with each clause such as SELECT, FROM and WHERE on its own line and its items indented below.
  • After Minify, the status shows the size before and after and the percentage saved. Formatting adds spaces around operators, so a query that was already compact can come out slightly larger, which shows as 0% smaller.
  • Minify joins all statements into a single line separated by semicolons, not one line per statement.
  • If the parser cannot read the input, the output turns red with Could not format this SQL and the parser's message. Fix the part it names and press Format again.

Tips and common mistakes

  • Remove line comments that start with two dashes before you press Minify. Minify joins every line, so the comment swallows the code after it and the query breaks.
  • Changing an option always switches the output back to the formatted view, even if you had just minified. Press Minify again afterward.
  • Keyword case changes SQL keywords such as SELECT and AND. Function names such as count and sum keep the case you typed.
  • Pick the right dialect for vendor specific syntax, such as square bracket names in SQL Server or backtick names in MySQL. The wrong dialect can trigger a parse error.
  • The formatter tidies layout only. It does not check that tables and columns exist or that the query will run.

Privacy and limits

Formatting runs in your browser with a copy of the sql-formatter library served from this site, not a third party CDN. Your SQL is not sent anywhere or saved, so it is safe to paste production queries.

Back to the tool

§ 02 · what you can do

Everything a formatter should do.

Beautify SQLPretty-print any query with consistent indentation and clause-aligned keywords for instant readability.
Minify SQLCollapse each statement to a single compact line, with the exact byte savings shown next to the result.
13 dialectsMySQL, PostgreSQL, SQL Server, BigQuery, Snowflake, Redshift, SQLite, Spark, Trino, Db2, Oracle PL/SQL and Standard SQL.
Your indent, your caseChoose 2 spaces, 4 spaces or tabs, and UPPERCASE, lowercase or preserved keyword casing.
Copy or downloadGrab the formatted output to your clipboard, or download it as a ready-to-run .sql file in one click.
Private by constructionEverything runs locally in your browser, paste production queries with zero upload, and it works offline.
§ 04 · faq

Frequently asked questions.

Is the SQL Formatter free?
Yes, completely free for everyone. No sign-up, no account and no usage limits.
Is it private? Is my SQL uploaded anywhere?
No upload, ever. The formatter runs entirely in your browser on your own device, your queries never leave your computer, so it is safe to paste production SQL.
Does it work offline?
Yes, once the page has loaded, formatting and minifying keep working without a connection, because all logic runs locally.
Which SQL dialects are supported?
Thirteen: Standard SQL, MySQL, MariaDB, PostgreSQL, SQL Server (T-SQL), BigQuery, SQLite, Redshift, Snowflake, Spark, Trino / Presto, Db2 and Oracle PL/SQL.
Does it validate my SQL?
Not fully. Formatting is lenient, it pretty-prints what you paste for readability rather than checking that the query is valid. If the parser hits input it can't read, it flags an error instead of producing broken output.
What is the difference between Format and Minify?
Format beautifies the query across multiple lines with your chosen indent and keyword case for reading and review. Minify does the opposite, it collapses each statement to one compact line (preserving text inside quotes) and reports how many bytes you saved.

Published · Last updated .

Priya sent you a message Online now

Talk to a Developer Now

Share your name and email to reply.

Reply