Developer Tools

SQL Formatter

Format SQL online for free: paste a messy query or upload a .sql file and get clean, readable SQL in 10 dialects (MySQL, PostgreSQL, SQL Server, SQLite, Oracle, BigQuery, Snowflake, Redshift, MariaDB), with indent, keyword case and minify options. 100% in your browser, no upload, no signup.

Your formatted SQL will appear here.

⚡ Formatting only changes whitespace and letter case: it never changes what the query does, and it never runs the query. Pick the dialect your database uses, because each one has its own keywords and functions, then copy the result into your editor or client.

🔒 Privacy: formatting runs locally in your browser with the sql-formatter library. Your SQL is never uploaded, stored or seen by anyone else, so queries with real table names and values stay on your device.

More developer tools

How this calculator works

A SQL formatter takes a query that was written in a hurry, or generated by a tool, and lays it out so a human can read it: one clause per line, consistent indentation, keywords in a single case, and long lists broken into readable rows. The query still does exactly the same thing, only the whitespace and the letter case change, which is why formatting is safe to run on any query, including one copied from production logs or a generated report. Paste your SQL here, or upload a .sql file, and the formatted version appears instantly, with a sample query if you want to see what the tool does first.

The dialect matters, because every database has its own SQL. MySQL, PostgreSQL, SQLite, SQL Server (T-SQL), Oracle PL/SQL, BigQuery, Snowflake, Redshift and MariaDB each have their own keywords, functions and syntax quirks: TOP belongs to SQL Server, LIMIT belongs to MySQL and PostgreSQL, and a formatter that does not know your dialect can misread a clause. This tool formats with the real sql-formatter parser for the dialect you pick, so TOP stays TOP on T-SQL and LIMIT stays LIMIT on PostgreSQL. The options cover the choices that change how the output looks: indent of 2 spaces, 4 spaces or a tab, keyword case in upper, lower or as typed, whether AND and OR start a new line or end one, and whether the semicolon sits on its own line. Minify mode does the opposite of formatting: it collapses the whole query to one line, handy for pasting into a config file or a URL, and it never touches the text inside string literals, so a value like 'New York' keeps its spaces.

Formatting is safe and private by design. The tool never runs your query: there is no database connection, no execution, and nothing that could change data, so a DELETE or UPDATE in the input comes back as formatted text and nothing more. Everything runs in your browser with the sql-formatter library, so queries with real table names, column names and values are never uploaded or stored. If the SQL cannot be parsed, for example an unterminated string or an unmatched parenthesis, the tool shows the parser's own error message and returns no output, so broken SQL never comes back looking fixed. Copy the result, or download it as a .sql file, and use the swap button to format it again with different options.

Frequently asked questions

How do I format SQL online?
Paste your SQL into the input box, or upload a .sql or .txt file. The formatted SQL appears instantly, with live character and line counts and the size change. Pick your dialect first (MySQL, PostgreSQL, SQL Server and 7 more), then copy the result or download it as formatted.sql. Nothing is uploaded: formatting runs in your browser.
Which SQL dialects does the formatter support?
Ten dialects: Standard SQL, MySQL, PostgreSQL, SQLite, SQL Server (T-SQL), Oracle PL/SQL, BigQuery, Snowflake, Redshift and MariaDB. Pick the one your database uses, because each has its own keywords and syntax: for example, TOP is SQL Server only, while LIMIT is MySQL and PostgreSQL. Formatting with the wrong dialect can misread a clause, so the dropdown is the first thing to check.
Does formatting change what my query does?
No. Formatting only changes whitespace and keyword letter case, never the logic, the tables, the filters or the values. The formatted query returns the same rows as the original. The tool never runs your query either: there is no database connection, so a DELETE or UPDATE in the input comes back as formatted text and nothing is executed or changed.
Is my SQL uploaded or stored anywhere?
No. Formatting runs locally in your browser with the sql-formatter library. Your SQL is never sent to a server, stored or seen by anyone else, so queries with real table names, column names and values stay on your device.
What does minify mode do?
Minify mode collapses the whole query to a single line, which is handy for pasting SQL into a config file, a URL or a chat message. It only collapses whitespace outside string literals, so a value like 'New York' keeps its spaces exactly as written. Formatting is the default; turn minify on when you need the smallest possible single-line version.
Why does the formatter show a parse error?
The SQL could not be parsed, most often because of an unterminated string (a missing closing quote) or an unmatched parenthesis. The tool shows the parser's own error message with the exact line and column, and returns no output, so broken SQL never comes back looking fixed. Fix the error and the formatted output appears. Note that the parser is lenient about some mistakes, so a query can format cleanly and still be wrong for your database: always run it against the real database before using it.
Disclaimer: Results are estimates for planning purposes only and are not financial advice. Actual loan terms, taxes and investment returns vary. Consult a qualified professional before making financial decisions.