Keep folders on top in Finder and on your Desktop
By default, macOS sorts Finder windows and the Desktop alphabetically — folders and files all mixed together. One setting pins folders to the top whenever you sort by name, so you always see your directories before any files. There are actually two separate switches: one for Finder windows, one for the Desktop.
Why this matters
When a folder holds dozens of files alongside subdirectories, the mixed alphabetical sort means you have to scan through the whole list to find a folder. With "Folders on top" enabled, all directories cluster at the top of the list and files follow below. It's especially useful in List view, where you might have hundreds of items and you just want to drill into a subfolder quickly.
Note that this setting only applies when Finder is sorted by name. If you sort by Date Modified, Kind, or Size, folders and files are mixed regardless.
The GUI way: Finder Settings
There are two separate checkboxes — one for Finder windows, one for the Desktop. You can enable either or both.
- In Finder, press ⌘, (or go to Finder › Settings in the menu bar).
- Click the Advanced tab.
- Under "Keep folders on top", check "In windows when sorting by name" to pin folders in Finder windows.
- Check "On Desktop" to pin folders on the Desktop as well.
- The change takes effect immediately — no relaunch needed when using the GUI.
The Terminal way
Both options are stored as separate defaults keys. Run whichever apply to you:
# Folders on top in Finder windows
defaults write com.apple.finder _FXSortFoldersFirst -bool true
# Folders on top on the Desktop
defaults write com.apple.finder _FXSortFoldersFirstOnDesktop -bool true
# Restart Finder to apply
killall Finder
You can run one or both commands. Finder relaunches automatically after killall Finder and the setting takes effect immediately.
How to undo it
To go back to the mixed alphabetical sort, uncheck the boxes in Finder Settings, or run the Terminal commands with false:
defaults write com.apple.finder _FXSortFoldersFirst -bool false
defaults write com.apple.finder _FXSortFoldersFirstOnDesktop -bool false
killall Finder
Mainspring's Folders on top toggle enables both the window and Desktop variants at once — no need to hunt through Finder Settings or type Terminal commands. Flip it off and everything goes back exactly as it was.
Try Mainspring free →Signed & notarized by Apple · 1-day free trial · $29 once
A few edge cases worth knowing
Column view: The "folders on top" preference also applies in Column view — subfolders appear at the top of each column's list when you sort by name.
Icon view: In Icon view, Finder arranges items by a grid rather than a strict list, so the visual effect is less obvious. The folders technically come first in the underlying order, but the grid layout can make it look inconsistent. List and Column view are where this setting shines.
Smart Folders and search results: The preference applies to regular folder windows. Smart Folders (saved searches) show results from Spotlight and may not respect the same ordering.
External drives and network shares: The setting applies to all Finder windows, including those showing external drives and network volumes, as long as you're sorting by name.