SQL formatter
✓ functionalTidy up a query without changing what it means. The formatter is careful on purpose.
The formatter is configurable, but it is deliberately cautious. SQLly re-lexes and compares its output token by token with the input; any mismatch leaves your SQL untouched. It can reindent, recase keywords, and align clauses without taking chances with comments or literals.
Mark a region to leave exactly as written when the formatter should keep its distance:
-- formatter:off SELECT weird , hand_aligned , columns -- left exactly as typed -- formatter:on
Minify SQL
Going the other way - one compact line for a log, a JSON payload, or a command line -
Minify SQL strips ordinary comments and collapses all whitespace to
single spaces while leaving string literals, quoted identifiers, and dollar-quoted
bodies untouched, so the compact SQL still runs exactly like the original.
-- sqlly directive comments and /*+ hint */ optimizer hints
are kept, a SQL Server GO separator keeps its own line because the server
requires it, and SQL that does not parse cleanly is left unchanged rather than mangled.
Select the SQL to compact - or place the caret in a statement, or select nothing to minify the whole query - and press ⌘⌥⇧F (Ctrl+Alt+Shift+F on Windows and Linux), choose Query › Minify SQL, or run it from the command palette. The result lands as a single undoable edit, so one undo restores your formatted SQL.