Back up your iPhone if needed
Open Settings
Tap General
Tap Transfer or Reset iPhone
Tap Erase All Content and Settings
Enter your passcode if prompted
Enter your Apple ID password if prompted
Confirm erase
Wait for the reset to finish
Set up the iPhone as new or restore from a backup
