Format SQL in DBeaver: shortcut, keyword case and settings
DBeaver has a SQL formatter built into its SQL editor, and unlike most editors in this list it is on by default with a sensible keybinding. What trips people up is the split between the formatter and the separate case commands — changing keywords to uppercase is not a formatting option in DBeaver, it is its own menu item — and the fact that the most flexible option, an external formatter, is buried in preferences and needs a binary on your machine.
Short answer
Built in and enabled by default
Select the SQL and press Ctrl+Shift+F, or right-click the selection and choose Format → Format SQL. Settings live at Window → Preferences → Editors → SQL Editor → Formatting.
- Windows
- Ctrl+Shift+F
- macOS
- Cmd+Shift+F
Step by step in DBeaver
- 01
Format the script
Highlight the statement you want reformatted and press Ctrl+Shift+F. With nothing selected the whole editor contents are formatted, which is worth knowing before you run it on a 2,000-line migration script. The same command is on the context menu under Format → Format SQL.
- 02
Change keyword case
This is a separate command, not a formatter setting. Select the SQL, right-click, and choose Format → To Upper Case or Format → To Lower Case. Because it is a distinct action, a plain Ctrl+Shift+F will not touch your casing — which is the answer to the very common complaint that DBeaver “won't uppercase my keywords”.
- 03
Open the formatting preferences
Window → Preferences → Editors → SQL Editor → Formatting. Here you pick the formatter engine and adjust indentation, line width and keyword casing behaviour. The preference page is where you switch from the default engine to Compact, or to an external one.
- 04
Wire up an external formatter
The Formatting preference page can hand your SQL to an external command instead of the built-in engine — pgFormatter is the usual choice for PostgreSQL shops. You point DBeaver at the executable and it pipes the statement through on every format. It gives you far more control, at the cost of a per-machine install that every teammate has to repeat.
- 05
Set it per connection where dialects differ
DBeaver's SQL editor settings can be overridden per connection. If you have one workspace connected to both Postgres and ClickHouse, setting formatting at the connection level stops one engine's conventions being applied to the other's queries.
MySQL, before and after
The unformatted query below is the sample loaded into the editor above, and the output is exactly what this formatter returns for it with the default options. Nothing was tidied up by hand.
SELECT u.id, u.email, COUNT(s.id) AS session_count, MAX(s.started_at) AS last_seen FROM users AS u LEFT JOIN sessions AS s ON s.user_id = u.id AND s.started_at >= ? WHERE u.signup_source = ? AND u.deleted_at IS NULL GROUP BY u.id, u.email HAVING COUNT(s.id) >= ? ORDER BY last_seen DESC LIMIT 200; SELECT
u.id,
u.email,
COUNT(s.id) AS session_count,
MAX(s.started_at) AS last_seen
FROM
users AS u
LEFT JOIN sessions AS s ON s.user_id = u.id
AND s.started_at >= ?
WHERE
u.signup_source = ?
AND u.deleted_at IS NULL
GROUP BY
u.id,
u.email
HAVING
COUNT(s.id) >= ?
ORDER BY
last_seen DESC
LIMIT
200; What DBeaver still won't do
None of this is a knock on DBeaver — these are just the edges of what an in-editor formatter is for. They are also the reason there is a formatter at the top of this page.
- The built-in engine is deliberately conservative and dialect-agnostic. It will not reflow modern analytical syntax — ClickHouse's PREWHERE, BigQuery's QUALIFY — the way a grammar-aware formatter does.
- The external formatter route works well but needs a binary installed on every machine, which makes “our team formats SQL the same way” a per-laptop chore.
- Casing lives outside the formatter, so a single keystroke never gives you both layout and case in one pass.
- Nothing here helps with placeholders, and nothing gives you a readable view of a heavily nested WHERE clause.
DBeaver SQL formatting FAQ
What is the DBeaver SQL format shortcut?
Ctrl+Shift+F on Windows and Linux, Cmd+Shift+F on macOS. It formats the current selection, or the entire script if you have not selected anything.
How do I make DBeaver uppercase SQL keywords?
Keyword case is a separate command, which is why formatting alone never changes it. Select the SQL, right-click, and choose Format → To Upper Case. Casing behaviour can also be configured under Window → Preferences → Editors → SQL Editor → Formatting.
Where are DBeaver's SQL formatting settings?
Window → Preferences → Editors → SQL Editor → Formatting. That page selects the formatter engine and its indentation, line-width and casing options, and is also where you configure an external formatter.
Can I use pgFormatter or another external formatter in DBeaver?
Yes. The Formatting preference page lets you nominate an external command that DBeaver pipes each statement through. It gives much finer control than the built-in engine, but every developer needs the binary installed locally for the team to get the same output.
Why does DBeaver format my ClickHouse query badly?
The built-in formatter is largely dialect-agnostic, so engine-specific clauses are not laid out the way that engine's own conventions would suggest. A grammar-aware formatter handles them properly — the one on this page has a native ClickHouse grammar and treats PREWHERE as a first-class clause.
Does formatting in DBeaver send my SQL anywhere?
No, the built-in formatter is local. The formatter on this page is local too, in the sense that matters — it runs inside your browser tab and your query is never sent to a server.
Verified 2026-08-20 against