Format SQL with clauses on their own lines and subqueries indented, across five dialects — or collapse a query to one line for embedding. Nothing is executed.
Standard SQL. Double quotes around identifiers, '' to escape a quote inside a string, and ? placeholders. The common subset every database below also understands. Identifiers and string literals are never recased — 'Alice' and 'ALICE' are different values, and in a database that quotes identifiers so are "Name" and "NAME".
Waiting for a query
Double quotes around identifiers, '' to escape a quote inside a string, and ? placeholders. The common subset every database below also understands.
Formatted SQL appears here
Clauses on their own lines, subqueries indented, and keywords cased however you like.
SQL Formatter runs entirely on your device — nothing is uploaded.
You’re on the Free plan. Compare plans
A query pulled out of a log or an ORM arrives as one long line. Formatting it — clauses on their own lines, columns listed vertically, subqueries indented — is usually the difference between reading it and guessing at it.
The tokenizer underneath knows the things that break naive SQL tools. A doubled quote inside a string is an escaped quote, not the end of the string, so 'it''s' is one value rather than two fragments. -- inside a string literal is two hyphens, not the start of a comment. PostgreSQL's dollar quoting, $$ … $$, can contain anything at all including semicolons, and function bodies routinely do. Block comments nest in PostgreSQL and not elsewhere. And identifiers are quoted four different ways depending on the database: double quotes, backticks, square brackets.
Five dialects are offered and the page says what each one changes rather than leaving you to find out: standard SQL, PostgreSQL, MySQL, SQLite and SQL Server. Picking the wrong one mostly affects how quoted identifiers and placeholders are read.
Two things are never recased, whatever you choose for keywords. String literals, because 'Alice' and 'ALICE' are different values. And identifiers, because in every database that supports quoted identifiers, "Name" and "NAME" are different columns.
The most important thing this page says is that formatting is not validation. The tokenizer will happily lay out SELECT FROM WHERE GROUP into a tidy block, and the database will still reject it. A clean format proves the text could be split into tokens and nothing more. Nothing connects to a database, no query is executed, and the query never leaves your browser.
No. The tokenizer can break almost anything into tokens and lay it out neatly, including a query the database will reject outright. Formatting proves the text could be tokenized and nothing more.
Standard SQL, PostgreSQL, MySQL, SQLite and SQL Server. The difference is mostly in identifier quoting, placeholder styles, whether block comments nest, and whether a double-quoted value is a string or an identifier.
Never. Strings are reproduced exactly, including their internal whitespace, doubled-quote escapes and dollar-quoted bodies. Keyword casing applies only to keywords.
No. There is no connection of any kind, no schema is fetched and no query is executed. Everything happens in your browser, which is what makes it safe to paste a query containing real values.
Removes the line breaks and collapses runs of whitespace between tokens, giving one line. It is for embedding a query in a string literal or a log line. It does not make the query faster — the database parses it the same either way.
Because one is a function call and the other is syntax. The formatter keeps a function name against its parenthesis and separates a keyword from the parenthesis after it, which is the convention every SQL style guide uses.
Yes. Formatting the output again returns the same text, so it will not oscillate between two layouts.