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.
Before & After
See the difference
Before (messy)
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;
After (formatted)
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
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.
Select (Optional)
To format specific code, select it first. To format the entire worksheet, just place your cursor anywhere.
Press Ctrl+F7
Windows: Ctrl + F7
Mac: Cmd + F7
Or right-click → Format
Other Ways to Format
If you prefer menus
Right-Click Menu
Right-click in the editor → Format
Edit Menu
Edit → Advanced → Format
Toolbar Button
Look for the document icon with lines in the toolbar (hover to see "Format")
Customize Formatting Rules
Make it match your style
Go to Tools → Preferences → Code Editor → Format to customize:
Indentation
Set indent size (2, 4, or 8 spaces). Choose tabs vs spaces.
Line Breaks
Control where lines break - after SELECT, before FROM, etc. Set max line length.
Keyword Case
Uppercase keywords (SELECT, FROM, WHERE) or lowercase - your choice.
Alignment
Align column lists, JOIN conditions, and WHERE clauses for readability.
Formatting Tips
Get the most out of the formatter
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.