How to erase your iPhone | Apple Support

To reset your iPhone to factory settings, ensure you have an iCloud or computer backup. On your iPhone, go to Settings > General > Reset > Erase All Content and Settings, enter your passcode, and follow prompts to turn off Find My and confirm erasure. Alternatively, on a Mac (Catalina or later) or PC with iTunes, disable Find My, connect your iPhone, trust the computer, select your device, and click Restore iPhone. Confirm erasure, wait for iOS installation, and your iPhone will restart. Follow on-screen setup instructions. Subscribe to Apple Support for more tips.

Summary:
Ensure you have an iCloud or computer backup before resetting.
– On iPhone: Go to Settings > General > Reset > Erase All Content and Settings.
– Enter passcode, disable Find My, and confirm erasure.
– On Mac (Catalina or later) or PC with iTunes: Disable Find My, connect iPhone, and select Restore iPhone.
– Confirm erasure, wait for iOS installation, and follow setup instructions after restart.