Back up your files with Time Machine or another backup method
Sign out of iCloud, iMessage, and other Apple services
Open System Settings or System Preferences
Go to General
Select Transfer or Reset
Click Erase All Content and Settings
Follow the on-screen prompts
Enter your Mac password and Apple ID if requested
Confirm the erase process
Wait for the Mac to restart and erase itself
Set up the Mac as new or shut it down if you are selling it
If your Mac does not support Erase All Content and Settings, restart into macOS Recovery
In macOS Recovery, open Disk Utility
Erase the startup disk
Return to Recovery and reinstall macOS
Complete setup or power off after installation
