Paste the query in the left box, or click the wand icon to load an example. The result appears on the right as you type.
Choose MySQL, PostgreSQL, SQL Server, SQLite, Oracle or Standard SQL so quoted names, comments and strings are read the way your database reads them.
Use 2 spaces, 4 spaces or a tab, and choose UPPERCASE, lowercase or "keep as typed" for keywords such as SELECT and WHERE.
Click Copy to paste the query into your editor, or Download .sql to save it. Click Minify to get a compact one-line version instead.
Each major clause starts on its own line and its contents are indented underneath. Columns in SELECT, GROUP BY and ORDER BY go one per line, joins line up under FROM, and AND / OR conditions in WHERE, HAVING and ON are split so every condition is easy to find.
Sub-queries in parentheses are indented as a block, CASE expressions are laid out with each WHEN and ELSE on its own line, and common table expressions (WITH) keep one query per CTE. Short things stay on one line: function calls such as COUNT(*), IN (1, 2, 3) lists and LIMIT 10.
The layout is the same for every dialect; the setting changes how the text is read. MySQL and MariaDB use `backticks` for names, # for comments and backslash escapes in strings. PostgreSQL supports $$ dollar-quoted strings and the :: cast. SQL Server and SQLite read [bracketed] names, and SQL Server also reads #temp tables and @variables.
If you are not sure, Standard SQL works for most queries. Switch the dialect when a name or string looks broken in the result.
The tool never rewrites your query: string values, table names, column names and comments are kept exactly as you wrote them. Keywords and well-known functions (COUNT, SUM, COALESCE...) follow the case you choose, while names that merely look like keywords, such as a column called "name" or "date", are left alone.
It is a formatter, not a validator. It does not know your schema and does not check the syntax against a database, but it warns you about an unclosed quote, comment or parenthesis and shows the line and column, which is usually where the typo is.
Minify removes line breaks, extra spaces and comments, producing a single line you can paste into a script, a config file or a log. Comments are dropped because a "--" comment would otherwise swallow the rest of the line. Optimizer hints such as /*+ INDEX(t i) */ are kept, since they change how the query runs.
Your SQL is formatted in your browser and never sent to a server. That makes it safe for queries that contain table names, customer data in literals or anything else you would not paste into an online service. Your dialect, indentation and keyword case are remembered in your browser for next time.
Paste it in the left box. It is formatted automatically as you type; you can also click Format. Then copy the result or download it as a .sql file.
Yes. Pick the dialect from the list. It affects how quoted names, comments and strings are read, for example `backticks` in MySQL, [brackets] in SQL Server or $$ strings in PostgreSQL.
No. Only spaces, line breaks and the case of keywords change. Strings, names and comments are kept as they are, so the query runs exactly as before.
No, it formats what you give it and does not check the syntax against a database. It does warn about an unclosed quote, comment or parenthesis and points to its line and column.
It turns the query into a single line without comments or extra spaces. Optimizer hints such as /*+ ... */ are kept because they affect execution.
No. Everything runs in your browser, so you can use it with production queries. Only your dialect, indentation and keyword choices are saved locally.
Yes. It is free, needs no sign-up and has no limit on the size or number of queries.