Moving to a new Mac? Before taking these steps, you can use Migration Assistant to move your files from the old Mac to your new Mac.
Create a backup
Make sure you have a current backup of your important files. Find out how to back up your Mac.
Sign out of iTunes in macOS Mojave or earlier
If you're using macOS Mojave or earlier, open iTunes. From the menu bar at the top of the screen or iTunes window, choose Account > Authorisations > Deauthorise This Computer. Then enter your Apple ID and password and click Deauthorise.
Find out more about deauthorising computers that use your iTunes account.
Sign out of iCloud
If you're using macOS Catalina or later, choose Apple menu > System Preferences, then click Apple ID. Select Overview in the sidebar, then click Sign Out.
If you're using macOS Mojave or earlier, choose Apple menu > System Preferences, click iCloud, then click Sign Out.
You will be asked whether you want to keep a copy of your iCloud data on this Mac. You can click Keep a Copy, because you will be erasing your Mac later. Your iCloud data remains in iCloud and on any other devices that are signed in to iCloud with your Apple ID.
Sign out of iMessage
If you're using OS X Mountain Lion or later, open the Messages app, then choose Messages > Preferences from the menu bar. Click iMessage, then click Sign Out.
Shut down your Mac, then turn it on and immediately press and hold these four keys together: Option, Command, P and R. Release the keys after about 20 seconds. This will clear user settings from the memory and restore certain security features that may have been altered previously.
Optional: Unpair Bluetooth devices that you’re planning to keep
If your Mac has been paired with a Bluetooth keyboard, mouse, trackpad or other Bluetooth device that you plan to keep, you can unpair it. This optional step prevents any accidental input or device connection when the Mac and Bluetooth device have separate owners but remain within Bluetooth range of each other.
If you're unpairing Bluetooth input devices from a desktop computer, such as an iMac, Mac mini or Mac Pro, you must plug in a USB keyboard and mouse to complete the remaining steps in this article.
To unpair a Bluetooth device, choose Apple menu > System Preferences, then click Bluetooth. Move your pointer over the device you want to unpair, then click the remove (x) button next to the device name.
Erase your hard drive and reinstall macOS
The best way to restore your Mac to its factory settings is to erase your hard drive and reinstall macOS.
After macOS installation has been completed, the Mac will restart and display a setup assistant asking you to choose a country or region. To leave the Mac in an out-of-box state, don't continue the setup process. Instead, press Command-Q to shut down the Mac. When the new owner turns on the Mac, the setup assistant will guide them through the setup process.
Irrespective of the model or condition of your device, we can turn it into something good for you and good for the planet: Find out how to trade in or recycle your Mac with Apple Trade In.