If you've come to the decision that jailbreaking isn't for you, you can come back to Apple's fold simply by restoring your iPhone. There's no need to manually delete the jailbreak apps you installed because the procedure deletes everything from the iPhone, returning the device to Apple's factory settings. Use iTunes or iCloud to back up your iPhone before restoring it. These backups ignore jailbreak apps, but back up important data like your photos, videos, text messages and device settings like your email account information. If, for any reason, you are unable to restore a jailbroken iPhone, you can use recovery mode to erase the device.
Backing up Jailbreak Apps
Before restoring an iPhone, take a good look at the jailbreak apps you downloaded and the data they contain. If you want to keep any of this data, you'll need to back it up yourself. Apple iCloud or iTunes backups will ignore these apps. If all of your photos aren't in Apple's Photos app, for example, they won't be saved when you do the restore. If you want a backup of your Cydia apps as well, you will need to install a backup app from Cydia and run it.
Backing up with iCloud
If you have unlimited Internet bandwidth, you can back up your iPhone with iCloud. First, connect your iPhone to a power source. Launch "Settings," select "iCloud" and then "Backup." Turn on the "Backup" option and enter your Apple ID if prompted. Tap the "Backup Now" button. Your iOS settings and data, such as your camera roll photos, are backed up to your iCloud account. If you exceed the free 5GB limit, a dialog box opens prompting you to manage your storage. Tap the "Settings" button in the dialog box and remove some of the files already in iCloud to make room for your backup.
Backing up with ITunes
Using iTunes to back up is usually faster than iCloud. Additionally, iTunes backs up all of your iOS apps to your computer so you don't have to download them again from the App Store. After installing the latest version of iTunes on your computer and logging in with your Apple ID, connect the iPhone to your computer's USB port. Select your iPhone when it appears in iTunes -- this is a button in the upper-right corner in iTunes 11. Click the "Summary" tab, then select the "This Computer" option in the Backup section and then click "Backup Now." This saves your backup to your computer.
Restoring the IPhone
If you used iTunes to back up your iPhone, click the "Restore" button under iTunes' Info tab to restore it when the backup is finished. If you decided not to use a backup, or if you used iCloud to back up the iPhone, launch "Settings," select "General," then "Reset" and then "Reset all Content and Settings." Once everything is erased, you're prompted to restore from your backup, either on iTunes or iCloud, or to set up the iPhone as a new device. Apps, music, movies and e-books you purchased from the App Store, iTunes or iBooks are always available in the the app's Purchased screen to download free of charge.
Using Recovery Mode
If the jailbreak software is preventing you from restoring an iPhone to its factory settings, you will have to put the iPhone into recovery mode. Unfortunately, this doesn't give you the opportunity to run a backup. However, you can access any old backups you made in iTunes or iCloud in the past. To do this turn off the iPhone, but don't connect it to its cable just yet. Connect the cable to your computer and launch iTunes. Then, while holding down the iPhone's Home button, connect the iPhone to its cable. Keep holding down the Home button until you see a "Connect to iTunes" message on the iPhone's screen. You can then release the Home button. You may need to try this two or three times before it works properly. When you've done it successfully, iTunes will detect the iPhone in recovery mode and prompt you to erase and reset all of its data and settings.