When you are ready to trade in, sell, give away or recycle your iPhone or iPad, here is the proper way to fully erase it:

  1. Open the Settings app and go to [your name] at the top. Scroll down to the bottom of the resulting page and tap Sign Out. Enter your Apple ID password and tap Turn Off. If it offers to keep copies of your data (Contacts, Calendars, etc.) decline that offer since we will be erasing the phone, anyway.

  2. Go back to the main Settings screen and scroll down to General. At the bottom of the resulting screen tap Transfer or Reset iPhone. On the resulting screen choose Erase All Content and Settings. Enter passwords and passcodes as they are prompted.

  3. Once your device reboots, it should ask you to select a language. This indicates that you erased it correctly. Turn the device off.

  4. On your newer iPhone or iPad open the Settings app and go to [your name] at the top. On the resulting page, scroll down to find your old device that you just erased. Tap it and then tap Remove from Account.

That’s it, your device is completely erased of all of your content and is no longer tied to your iCloud account.