sqlfmt is an online SQL formatter. It is pronounced sequel fumpt. Its purpose is to beautifully format SQL statements.
There is a box in which to paste or type SQL statements. Multiple statements are supported by separating them with a semicolon (;
). The slider below the box controls the desired maximum line width in characters. Various options on the side control tab/indentation width, the use of spaces or tabs, simplification, and alignment modes. Simplification causes the formatter to remove unneeded parentheses and words when the meaning will be the same without them.
There are four alignment modes. The default, no
, uses left alignment. partial
right aligns keywords at the width of the longest keyword at the beginning of all lines immediately below. full
is the same as partial
but the keywords AND
and OR
are deindented, in a style similar to the sqlite tests. other
is like partial
but instead of deindenting AND
and OR
, their arguments are instead indented.
SELECT a FROM t WHERE c AND b OR d
SELECT a FROM t WHERE c AND b OR d
SELECT a FROM t WHERE c AND b OR d
SELECT a FROM t WHERE c AND b OR d