Skip to main content
SQL Developer — help/format-sql.md
Ctrl+F7

How to Format SQL in SQL Developer

Turn messy SQL into clean, readable code with one shortcut. Customize formatting rules to match your team's style guide.

~/formatter.spec shortcut overview

# Format action

shortcut_win = Ctrl + F7

shortcut_mac = Cmd + F7

alt = right-click → Format · Edit → Advanced → Format

# Configuration

config = Tools → Preferences → Code Editor → Format

rules = indent · line breaks · keyword case · alignment

scope = selection (if any) or entire worksheet

undo = Ctrl+Z (single action)

time = instant

// idempotent — formatting twice yields the same result

Before & After

See what the formatter does in one step.

~/demo/messy.sqlbefore

select u.id,u.name,u.email,o.order_date,o.total from users u inner join orders o on u.id=o.user_id where o.status='completed' and o.total>100 order by o.order_date desc;

~/demo/clean.sqlafter

SELECT u.id,

u.name,

u.email,

o.order_date,

o.total

FROM users u

INNER JOIN orders o

ON u.id = o.user_id

WHERE o.status = 'completed'

AND o.total > 100

ORDER BY o.order_date DESC;

Format SQL Instantly

One shortcut does it all. Three steps.

STEP_01

Write or Paste SQL

Enter your SQL in the worksheet. It doesn't matter how messy it is — single line, no indentation, inconsistent spacing — all fine.

STEP_02

Select (Optional)

To format specific code, select it first. To format the entire worksheet, just place your cursor anywhere.

STEP_03

Press Ctrl+F7

Windows: Ctrl + F7
Mac: Cmd + F7
Or right-click → Format

Other Ways to Format

If you prefer menus over keyboard shortcuts.

  • Right-click menu — right-click in the editor → Format
  • Edit menuEdit → Advanced → Format
  • Toolbar button — look for the document icon with lines in the toolbar (hover to see "Format")

Customize Formatting Rules

Go to Tools → Preferences → Code Editor → Format to customize:

RULE

Indentation

Set indent size (2, 4, or 8 spaces). Choose tabs vs spaces.

RULE

Line Breaks

Control where lines break — after SELECT, before FROM, etc. Set max line length.

RULE

Keyword Case

Uppercase keywords (SELECT, FROM, WHERE) or lowercase — your choice.

RULE

Alignment

Align column lists, JOIN conditions, and WHERE clauses for readability.

Formatting Tips

Three practical habits that make the formatter pay off.

  • Format before committing — always format your SQL before saving to version control. Consistent formatting makes code reviews easier.
  • Save format profiles — create different format profiles for different projects. Export and share with your team for consistency.
  • Undo if needed — don't like the result? Just press Ctrl+Z to undo. Formatting is a single undoable action.

Related Guides

Useful neighbours for SQL editing.

~/downloads ready.sh

Next: Memorize the Other Shortcuts

Ctrl+F7 is one of 50+ shortcuts SQL Developer ships with. The cheat sheet covers query execution, code editing, navigation, and file operations — most of the daily-use ones are F5, Ctrl+Enter, Ctrl+/, Ctrl+Space.

// next.speckeyboard-shortcuts.md · 50+ hotkeys
// see-alsorun-sql-script.md · F5