Before wiping the phone clean of personal information, make sure the important data you’d like to keep is backed up. See more about how to backup your data here. You’ll also need to remove your iCloud account from your device— learn about that here.
Now that your data is backed up and your iCloud account is no longer associated with your iPhone, there is one last important step to prepare your phone for sale: removing your personal information.
To erase all personal data from your device, just go to Settings > General > Reset > and select “Erase All Content and Settings”. It will ask you to confirm this action and require you to input your passcode. Once this is done, your phone will show a loading screen for a while, after which, your iPhone will be permanently cleared of all your personal data and restored back to its factory settings.