How do I erase an iPhone?

To erase everything and restore the iPhone to the factory state, go into Settings, then General, then Reset. Press "Erase All Content and Settings". If you have a passcode, you will be prompted to enter it. Select "Erase iPhone" and the wipe will begin. Be sure to have your iPhone connected to a power source as the erase takes a long time. When it's complete, the iPhone will have no SMS, calendar, phone logs, contacts, etc.


You can achieve this with a restore in iTunes. It will restore the iPhone to it's factory state, after which you can optionally restore from a backup. Here is a summary and guide from Apple on the subject.