Format and beautify SQL for PostgreSQL, MySQL, SQL Server and more
Runs in your browser. Nothing you type is sent anywhere. Updated on 24 Oct 2026.An unformatted query stops being readable the moment it passes 20 lines. This indents SQL for PostgreSQL, MySQL, SQL Server and other dialects, aligning clauses so joins and conditions line up. The query is formatted in your browser, so production SQL is never sent anywhere.
Pick your database under Dialect.
Paste the query into the SQL pane, or click Try an example.
Choose UPPER, lower or As typed for Keywords and an Indent width; Minify puts it on one line instead.
Click Copy, or the download icon to save a .sql file.
This SQL formatter takes a query of any length and lays it out so it can be read: every clause on its own line, selected columns listed one per line, joins and conditions indented, and keywords in the case you prefer. Paste on the left and the formatted SQL appears on the right as you type.
It helps whenever SQL reaches you in a form nobody wrote by hand. A query captured from an ORM log or a slow-query report arrives as one long line; a colleague's view definition has inconsistent indentation; a report from a BI tool nests three subqueries without a single line break. Formatting first makes a code review or a performance investigation much faster.
Choose the dialect so its own syntax is understood: PostgreSQL casts and dollar-quoted bodies, MySQL backtick names, SQL Server square brackets and TOP, BigQuery project paths, SQLite, or standard SQL. Pick upper, lower or unchanged keyword case, two spaces, four spaces or tabs, or minify the query back onto one line without comments for embedding in code.
If the formatter cannot read the query, you get the line and column and a plain hint, such as a string that is never closed or a query that ends too early, instead of a wall of parser output. Formatting only changes layout and case; it never changes what the query does. Everything runs in your browser, so queries containing table names or customer data never leave your device. Related tools: JSON Formatter, Diff Checker.
Yes, free with no signup, no account and no limit on query length or on how many queries you format. The page is supported by a few ads shown outside the tool, never inside the editor, and no dialect or option is held back for a paid tier.
No. Formatting runs in your browser with JavaScript, so a query never leaves your device. Table names, connection strings and customer data inside the SQL stay local, and nothing is logged. Only the four settings you chose, dialect, keyword case, indent and minify, are remembered on this device.
Six dialects: PostgreSQL, MySQL, SQLite, SQL Server (T-SQL), BigQuery and standard SQL. Choosing the right one lets the formatter understand syntax that belongs to that database, such as PostgreSQL :: casts, MySQL backtick names, SQL Server square brackets and TOP, and BigQuery backtick-quoted table paths.
Yes. Choose Upper to write SELECT, FROM and functions such as COUNT in capitals, Lower for lower case, or Preserve to keep the case you typed. Table and column names are never changed.
No. Only whitespace, line breaks and the case of keywords change, so the query you get back runs exactly as the one you pasted. Strings, quoted identifiers and values are copied character for character. Minify also strips comments, which is the one change worth noticing before you commit the result.
The formatter reached the end while a bracket or clause was still open, for example WHERE with no condition or a ( with no matching ). Check the end of the query, or switch the dialect if the syntax belongs to another database.
Still stuck? Ask about SQL Formatter and anybody who knows can answer. No account needed.
Also works as: SQL Beautifier.
Same job, other tools: JavaScript Beautifier – Reformat JavaScript with Prettier, in the indent style you use · GraphQL Validator – Check a GraphQL query or schema for errors, optionally against your own SDL · JSON Minifier – Strip whitespace from JSON for production · HTML Minifier – Strip comments and spare whitespace from HTML and see the saving · CSS Minifier – Compress a stylesheet and see exactly how many bytes you saved.
On the related tools: Markdown to HTML – Convert Markdown into clean, safe HTML you can paste anywhere.
In the collection Code Formatters and Minifiers.