Settings > [your name]. Scroll down and tap Sign Out. Enter your Apple ID password and tap Turn Off.
Go back to Settings and tap General > Reset > Erase All Content and Settings. If you turned on Find My [device], you might need to enter your Apple ID and password.
If asked for your device passcode or Restrictions passcode, enter it. Then tap Erase [device].
If you no longer have your iPhone, iPad, or iPod touch
If the steps above weren't completed and you no longer have your device, use these steps:
If you're using iCloud and Find My [device] on the device, sign in to iCloud.com or the Find My app on another device, select the device, and click Erase. After the device has been erased, click Remove from Account.
If you're using Apple Pay, you can remove your credit or debit cards at iCloud.com. Choose Settings to see which devices are using Apple Pay, then click the device. Next to Apple Pay, click Remove.
Log out of any accounts you have on the phone, including apps, emails and your Google account. To log out of your Google account tap on Settings > Accounts > Google > More > Remove account.
To perform a factory reset which will wipe your data: Go to your device’s settings Tap on System > Advanced > Reset options Tap on Erase all data (factory reset) > Reset phone. You may be required to enter your phone’s pin, pattern or password.