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.
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.
