About SQL Formatter
A SQL formatter makes long queries readable: a one-line statement copied from an application log or ORM debug output, a report query someone wrote years ago, or SQL you're about to paste into a code review or a ticket. Paste the query or open a .sql file, and the formatted version appears as you type. If the query runs on a schedule, the Cron Expression Generator builds the timing and lists the next run times.
New lines start before SELECT, FROM, WHERE, GROUP BY, ORDER BY, HAVING, LIMIT, each kind of JOIN, UNION, INSERT, VALUES, UPDATE, SET and DELETE. Selected columns go one per line, AND and OR conditions line up, and subqueries are indented. Keywords can be upper case, lower case or left as typed, and the indent is 2 spaces, 4 spaces or tabs. Text in single quotes, double quotes, backticks and square brackets is never split, and comments are kept, so it copes with MySQL, PostgreSQL, SQL Server, Oracle and SQLite. Tick One line to do the reverse and put the whole query on a single line. It all runs in your browser.
How to use SQL Formatter
- 1Paste your SQL
Paste the query or open a .sql file.
- 2Set keyword case and indent
Choose SELECT, select or As typed, then 2 spaces, 4 spaces or tabs.
- 3Copy the result
Copy or download the formatted SQL, or tick One line to get it on a single line.
Why use Cubfile for this
- A line per clause
SELECT, FROM, WHERE, JOIN, GROUP BY and the rest each start a new line.
- Readable conditions
AND and OR line up, columns go one per line and subqueries are indented.
- Every quoting style
Quoted text in '…', "…", `…` or […] is never split, and comments are kept.
- One-line option
Squeeze a query onto a single line for code strings and config files.