If you own the iPhone, use Recovery Mode with a Mac or PC
Connect the iPhone to a computer with a USB cable
Put the iPhone into Recovery Mode
On a Mac with Finder or a PC with iTunes, select the iPhone when it appears
Choose Restore to erase the iPhone and install the latest iOS
If Find My iPhone is enabled, use iCloud Find Devices
Go to iCloud.com/find on a computer or another device
Sign in with the Apple ID linked to the iPhone
Select the iPhone from the device list
Choose Erase This Device
If the iPhone is disabled and linked to your Apple ID, use the Apple Support app or another trusted device to erase it remotely
If you cannot access the Apple ID, contact Apple Support with proof of purchase
If the iPhone is managed by an organization, contact the organization’s IT administrator
After erasing, set up the iPhone again or restore from a backup
