SQL Formatter — One Clause per Line and Keywords in Capitals
Format SELECT/JOIN/WHERE clauses cleanly with uppercased SQL keywords.
- Only spaces, line breaks and the capitals of keywords change. Quoted strings, quoted names ("…", `…`, […]), comments, parameters (?, :name, @id, $1) and ::text casts stay exactly the same and in order.
- Keywords are only capitalised when MySQL reserves them, so table or column names such as user or date never change. One-line layout drops comments.
When to use the SQL Query Beautifier & Keyword Uppercase Formatter
Long queries made readable
SELECT, FROM, WHERE, GROUP BY, ORDER BY and every JOIN start on a new line. Selected columns go one per line, AND and OR are indented, and subqueries in brackets get their own indentation level.
Only the layout changes
Quoted strings, quoted names such as "full name", `order` or [total], comments, parameters ?, :name, @id, $1 and ::text casts stay exactly the same. Testing reads every result back with a separate SQL tokenizer and gets the same token sequence.
Capitals that are safe
Keywords are only capitalised when MySQL reserves them. Names such as user, date or first never change, because MySQL table names can be case-sensitive on Linux servers.
Formatted or one line
Choose one clause per line for reading and review, or one line to paste into application code and logs. The one-line layout drops comments so a line comment cannot swallow the rest of the query.
Frequently asked questions
Which SQL dialects are supported?
MySQL/MariaDB, PostgreSQL (dollar-quoted text, E'…', ::type and ->> included), SQL Server ([name], @variables) and SQLite.
Why are some keywords not capitalised?
Words such as offset, first or view are not reserved by MySQL, so they might be table or column names. They are left as you wrote them so that database object names never change.
Can it format several queries at once?
Yes. Each statement ending in a semicolon is separated by a blank line.
Is the query run?
No. The query is only read and rewritten, never sent to a database.
Is my data uploaded?
No. Everything runs in your browser.
Similar tools
- HTML Beautifier & Indentation PrettifierRe-indent messy single-line HTML markup into readable nested element trees.
- HTML Whitespace & Comment MinifierCompress HTML documents by removing redundant whitespace & HTML comments.
- HTML to Clean GitHub Markdown ConverterConvert headings, links, bold/code tags & lists from HTML into clean Markdown.
- Markdown Live Previewer & HTML GeneratorWrite Markdown and simultaneously render clean semantic HTML & live preview.