1. Tap Settings > General > Reset
Then tap Erase All Content and Settings.
2. If asked, enter your passcode or Apple ID password
3. Wait for your device to erase
Depending on your device, it can take a few minutes to completely erase your data.
Restore your iPhone
- Make sure your iPhone isn't connected to your computer.
- Press and hold the Side button and one of the volume buttons until the power off slider appears. Drag the slider to turn off your iPhone. Then connect your iPhone to your computer while holding the Side button. Keep holding the Side button until you see the recovery mode screen.
3. Locate your iPhone on your computer. When you see the option to Restore or Update, choose Restore. The Finder or iTunes will download software for your iPhone. If it takes more than 15 minutes, your iPhone will exit recovery mode and you'll need to select your iPhone model above and repeat the steps to remove the passcode.