How to Format SQL in DBeaver

Published: September 11, 2026 | Updated: September 11, 2026

DBeaver is a free, cross-platform database client, and unlike most of its competition it actually ships with a real SQL formatter. If your query scripts come out of a legacy tool looking like one long line, you do not need a plugin or a paid add-in — the DBeaver format SQL feature is already there, one shortcut away.

This guide covers the built-in formatter and its shortcut, how to build and tune a formatting profile (indentation, keyword case, comma and line-break rules), how to export that profile so your whole team formats SQL the same way, how to wire DBeaver into an external formatter toolchain, and what to do when the formatter mangles Chinese characters, comments, or chokes on very large files. If you just need to clean up one query right now, paste it into our free online SQL formatter instead.

Table of Contents
  1. Format SQL in DBeaver with Ctrl+Shift+F
  2. Configure the Formatter: Profiles, Indentation, Keyword Case
  3. Export & Import Formatting Profiles for Your Team
  4. DBeaver + External Toolchain: Format on Save
  5. DBeaver vs DataGrip vs SSMS vs VS Code
  6. Common DBeaver Formatting Problems and Fixes
  7. FAQ — DBeaver SQL Formatter

1. Format SQL in DBeaver with Ctrl+Shift+F

DBeaver bundles its own SQL formatter. Since version 6 it replaced the old Eclipse-based formatter, and it now understands SQL dialects well enough to keep CTEs, window functions and dialect-specific syntax intact.

The default shortcut is Ctrl+Shift+F (Windows/Linux) or Cmd+Shift+F (macOS). There are three ways to trigger it:

Here is a query that was pasted in from a log file. Everything is on one line, keywords are lowercase, and there is no spacing around operators:

select u.id,u.email,count(o.id) as orders from users u left join orders o on o.user_id=u.id where u.created_at>='2026-01-01' and u.status='active' group by u.id,u.email having count(o.id)>3 order by orders desc;

After pressing Ctrl+Shift+F with a default profile (keywords upper, 4-space indent), DBeaver reflows it into something a human can read and diff:

SELECT
    u.id,
    u.email,
    COUNT(o.id) AS orders
FROM
    users u
    LEFT JOIN orders o ON o.user_id = u.id
WHERE
    u.created_at >= '2026-01-01'
    AND u.status = 'active'
GROUP BY
    u.id,
    u.email
HAVING
    COUNT(o.id) > 3
ORDER BY
    orders DESC;

Every change the formatter makes is a normal editor edit, so Ctrl+Z undoes it in one step. If a profile reformats a file in a way you dislike, back out and edit the profile instead of the SQL.

Tip: Formatting only the selection is the safe default while you are dialing in a profile. That way an imperfect rule set cannot rewrite a 2,000-line migration script faster than you can undo it.

2. Configure the Formatter: Profiles, Indentation, Keyword Case

The formatter is configured under Window > Preferences > Editors > SQL Editor > Formatting (on macOS the same page lives under DBeaver > Settings > Editors > SQL Editor > Formatting). In older builds the page is labelled Code Formatting; the options are the same.

Formatting profiles

At the top of the page there is a formatting profile selector. DBeaver ships a small set of presets you can switch between, and you can derive your own:

  1. Open the Formatting page and pick the preset closest to your target style.
  2. Tune the options below it (indentation, keyword case, line breaks, alignment).
  3. Use the profile controls to save the tweaked set under a new name, e.g. team-postgres.
  4. Press Apply and Close, then re-format a script to confirm the result.

Indentation and whitespace

Keyword and identifier case

The formatter can change the case of keywords, data types, functions and identifiers independently. Each has Upper, Lower and Keep as is options:

A conservative starting point: keywords upper, everything else keep-as-is.

Line breaks, commas and alignment

These options decide how clauses are split and how lists are laid out:

Apply a profile, then format a representative query to see the result. A dialect with heavy boilerplate — say PL/SQL with nested blocks — is the best template to test on, because it exposes bad indentation rules immediately.

3. Export & Import Formatting Profiles for Your Team

A DBeaver formatting profile is not a standalone file you can commit — it lives inside the workspace preferences. That said, there are two practical ways to get identical formatting across a team.

Option A: Eclipse preference export (.epf)

DBeaver is built on the Eclipse platform, so it inherits Eclipse's preference export:

  1. File > Export > General > Preferences.
  2. In the export dialog, restrict the exported preferences to the SQL editor keys (a filter keyword such as dbeaver narrows it down) so you do not ship unrelated UI settings.
  3. Choose a destination and finish. You get an .epf file.
  4. Commit that .epf to your repo, or attach it to your onboarding notes.

Teammates import it with File > Import > General > Preferences, select the file, and restart DBeaver. Their formatter now behaves exactly like yours.

Option B: copy the workspace preference file

For scripted or headless setup, the profile lives in a plain text preference file inside the DBeaver workspace. The locations to know:

# Linux
~/.local/share/DBeaverData/workspace6/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.jkiss.dbeaver.ui.editors.sql.prefs

# Windows
%APPDATA%\DBeaverData\workspace6\.metadata\.plugins\org.eclipse.core.runtime\.settings\org.jkiss.dbeaver.ui.editors.sql.prefs

# macOS
~/Library/DBeaverData/workspace6/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.jkiss.dbeaver.ui.editors.sql.prefs

Copy that file into a new install before DBeaver first starts, and the formatter settings — along with the rest of the SQL editor preferences — are already in place. This is the approach to use when you provision developer machines from a script rather than asking each person to click through the import dialog.

Note: this file carries other SQL editor settings too, so treat it as "editor config". To share only the formatting rules, use the .epf export in Option A.

4. DBeaver + External Toolchain: Format on Save

DBeaver has no native "format on save" checkbox. If you want SQL formatted automatically rather than by pressing a shortcut, you have two routes: let DBeaver call an external formatter, or format outside DBeaver with a hook.

Route 1: the built-in external formatter hook

On the Formatting preference page, the formatter selector can be switched from DBeaver to External formatter. You then supply the command line for a tool that reads SQL from standard input and writes the formatted result to standard output. Any CLI formatter works — for example the popular Node sql-formatter:

sql-formatter --language postgresql

Or pg_format for PostgreSQL, or sqlfluff format --dialect postgres. The advantage is that the same binary can run in your editor, in a pre-commit hook and in CI, so the output is byte-for-byte identical everywhere.

Route 2: format-on-commit with a hook

The more robust pattern is to leave DBeaver's own formatter on for interactive work and enforce the canonical style at commit time. A pre-commit hook using SQLFluff does exactly that — DBeaver reloads the modified file from disk, so the SQL you committed is the SQL you see:

# .pre-commit-config.yaml
- repo: https://github.com/sqlfluff/sqlfluff
  rev: 3.0.0
  hooks:
    - id: sqlfluff-fix
      args: ["--dialect", "postgres"]

SQLFluff is deliberately stricter than DBeaver's formatter: it is rule-based, dialect-aware and configurable through a .sqlfluff file that you commit alongside the SQL. That makes it the natural way to keep a large repository consistent when several people format on different machines, or with different DBeaver profiles.

Format SQL Online — No Install Needed

Working outside DBeaver, reviewing a query in a browser, or on a machine without your setup? Paste the SQL, pick the dialect, and format it instantly. Everything runs in your browser.

Open SQL Format Tool →

5. DBeaver vs DataGrip vs SSMS vs VS Code

The four tools people most often compare for SQL formatting behave quite differently. The table below is the honest summary — DBeaver is the only free option with a genuinely configurable built-in formatter and a documented external-formatter hook.

CapabilityDBeaverDataGripSSMSVS Code
Built-in formatterYes, full engineYes, full engineBasic (keywords + indent)No — extension required
Default shortcutCtrl+Shift+FCtrl+Alt+LCtrl+K, Ctrl+DShift+Alt+F
Named formatting profilesYes (built-in profiles)Yes (code styles, XML export)Very limitedThrough the extension's config
Keyword-case controlYes, per token typeYesUppercase onlyYes, per extension
Comma / line-break strategyYesYesNoYes
External formatter hookYes (stdin/stdout command)Yes (file watchers)Only via add-insYes, via extensions
Native format on saveNoNo (plugin)NoYes
Dialect coverageVery broad (drivers + formatter)BroadT-SQL onlyDepends on extension
PriceFree (Community)Paid subscriptionFreeFree

Short version: DBeaver for a free, capable formatter inside a database client; DataGrip if you already pay for JetBrains tools; SSMS only if a basic reformat is enough. For format-on-save in an editor, see our VS Code SQL formatter guide and formatting SQL in SSMS.

6. Common DBeaver Formatting Problems and Fixes

Chinese (CJK) characters and comments shift position

This is the most common complaint from developers who write SQL with Chinese comments or string literals. DBeaver's formatter measures a line in characters, not in display columns, and a full-width CJK character occupies roughly two monospace cells. When alignment is enabled, the formatter pads a comment or a column based on character count, so the visible result is a ragged edge — comments jump left or right, and aligned AS aliases no longer line up.

What actually helps, in order of effort:

The editor freezes on large files

Formatting a multi-thousand-statement dump — the kind of file you get from a full pg_dump — can hang the DBeaver UI for tens of seconds or exhaust the heap entirely. The formatter parses the whole script before it emits output, and on a huge file that is simply a lot of work.

Quoted identifiers get re-cased

If your schema uses quoted mixed-case identifiers ("UserAccount") and the formatter rewrites them to "useraccount", the query silently stops matching the table. Set Identifiers and Functions to Keep as is in the profile. Keyword casing is safe; identifier casing is not.

The formatted result is not what you wanted

Press Ctrl+Z immediately — the format is a single editor operation and undoes cleanly. Then change the profile rather than hand-fixing the SQL, because the next format will undo your hand edits anyway.

7. FAQ — DBeaver SQL Formatter

How do I format SQL in DBeaver?

Open the editor and press Ctrl+Shift+F (Cmd+Shift+F on macOS) to format the whole script, or select a block and press the same shortcut to format just the selection. The menu equivalent is SQL Editor > Format > Format SQL, also available from the editor right-click menu.

Does DBeaver have a built-in SQL formatter?

Yes. Since version 6 it ships its own formatter, which replaced the old Eclipse one. It handles indentation, keyword case, line breaks, comma placement and alignment, and is configured under Window > Preferences > Editors > SQL Editor > Formatting.

How do I change keyword case or indentation in DBeaver?

Open the Formatting preference page, select a formatting profile, then set the tab and indent size, choose spaces or tabs, and set the keyword case to Upper, Lower or Keep as is. Line-break, comma and alignment rules are on the same page. Press Apply and Close and re-format a query to check the result.

Can I share DBeaver formatting settings with my team?

Yes, two ways. Export with File > Export > General > Preferences to produce an .epf file that teammates import via File > Import > General > Preferences, or set up new machines by copying the org.jkiss.dbeaver.ui.editors.sql.prefs file in the workspace .settings folder.

Why does formatting misalign Chinese characters or comments?

The formatter counts characters rather than display width, and full-width CJK characters take about two cells, so aligned text drifts. Disable the alignment options, keep line comments on their own lines, format a selection instead of the whole file, or switch to an external formatter such as SQLFluff that handles Unicode width correctly.