A factory reset will remove most malware, but not all of it

A factory reset — also called a hard reset or restore to factory settings — wipes your device's storage and reinstalls the original operating system. This process removes the vast majority of malware because malware lives in the files and apps on your device, and a factory reset deletes all of those. However, some types of malware can survive a factory reset, particularly firmware-level threats that live in the device's permanent memory rather than its storage drive.

The practical answer for most people is yes: a factory reset will solve a malware problem. But the reason matters, because it affects whether you should reset, what to do after, and whether you might get infected the same way again.

Key Takeaways

  • A factory reset removes nearly all malware because it deletes the files and apps where malware lives, but some advanced threats can hide in firmware and survive the process.
  • Malware that spreads through your email, downloads, or app store will return after a reset if you restore from a backup or reinstall the same apps without checking them first.
  • After a factory reset, set up your device fresh rather than restoring from a backup if you want to be certain the malware is gone.
  • If a device keeps getting infected with the same malware after multiple resets, the problem may be your network, email account, or a compromised app you keep reinstalling.

What a factory reset actually deletes

When you factory reset a device, the operating system erases the main storage drive — the place where your apps, files, photos, and settings live. Malware stored there gets deleted along with everything else. This includes viruses, spyware, ransomware, and most trojans, because they exist as files or code within apps that live on your storage.

The reset then reinstalls a clean copy of the operating system from the manufacturer's original files. On Windows computers, this might be Windows 11 as it came from Microsoft. On iPhones, it reinstalls iOS. On Android phones, it reinstalls the version that came with your device. This clean operating system has no malware in it.

The catch is that some malware can hide in places a factory reset does not touch. Firmware — the permanent software that controls your device's hardware — lives separately from your main storage. On some devices, malware can burrow into firmware and survive a factory reset because the reset only touches the storage drive, not the firmware. This is rare in consumer devices but possible in older or heavily compromised systems.

When malware comes back after a reset

You reset your device, and a week later the same malware returns. This does not mean the reset failed. It means you reintroduced the malware yourself by restoring from a backup or reinstalling an infected app.

If you restore from a backup — whether from cloud storage like iCloud or Google Drive, or from a local backup file — you restore the malware along with your files and settings. The backup was made when your device was already infected, so it contains the malware. This is why security experts recommend setting up your device fresh after a reset rather than restoring from backup.

Malware also returns if you reinstall the same app that was infected. If you had a trojan hidden inside a game or utility app, and you reinstall that app from the app store without checking whether it is still compromised, you get infected again. This is especially common with sideloaded apps on Android — apps installed from outside the official Google Play Store — because those sources have less security review.

Email is another common reinfection route. If malware came through a malicious email attachment or link, and you did not change your email password, the attacker can send you the same malware again. Resetting your device does not change your email account.

How to reset without bringing malware back

After a factory reset, set up your device as new rather than restoring from backup. This means entering your email address and passwords fresh, but not importing your old files, photos, or settings from a backup. You lose nothing permanent — your email, photos in cloud storage, and documents in cloud apps are still there — but you avoid restoring malware along with them.

Reinstall apps one at a time from official sources only. On iPhone, use the App Store. On Android, use Google Play Store. Avoid sideloaded apps or apps from third-party stores unless you have a specific reason and you trust the source. After reinstalling each app, use your device for a few days and watch for the same symptoms that indicated malware before — unexpected pop-ups, battery drain, overheating, or slow performance.

Change your email password before you set up your device again. If malware came through email, the attacker may still have access to your account. A new password locks them out and prevents them from sending you infected files again.

If you use cloud backup — iCloud on iPhone, Google Drive on Android — you can restore your photos, documents, and contacts from that backup after the reset, because cloud services scan for malware. What you should not restore is a full device backup or a backup of your app data, because those can contain malware.

Signs that malware survived the reset

If your device shows the same malware symptoms within days of a factory reset — pop-ups, unexpected app behavior, battery draining fast, or performance problems — the malware was reintroduced, not because the reset failed. Check whether you restored from a backup, reinstalled an old app, or logged into an email account that is still compromised.

If the same malware returns even after you set up fresh without restoring backup, the problem may be your network. Some malware spreads through compromised WiFi networks or routers. If you are on a shared network — at work, school, or a shared apartment — the network itself might be infected and reinfecting your device. Try using mobile data instead of WiFi for a few days to see if the problem stops.

Repeated infections of the exact same malware after multiple resets is also a sign that your email account is compromised. The attacker is sending you infected files or links repeatedly. In this case, change your email password, enable two-factor authentication on your email account, and review your email recovery options to make sure the attacker has not locked you out.

When a factory reset is not enough

In rare cases, malware lives in your device's firmware and survives a factory reset. This is more common on older devices or devices that have been heavily compromised over a long time. If a device keeps getting infected with the same malware even after multiple factory resets and fresh setups, and you have ruled out backup restoration and reinfection through apps or email, firmware malware is possible.

If you suspect firmware malware, contact the device manufacturer's support line. They can sometimes push a firmware update that removes the malware. For some devices, this requires sending the device to a service center. For others, it can be done remotely. This is not a common scenario, but it is worth knowing about if you are dealing with a persistently infected device.

Frequently Asked Questions

Do I lose all my files and photos when I factory reset?

Yes, a factory reset deletes everything on your device's storage. Photos, documents, and files stored only on your device are gone. However, if your photos are backed up to iCloud, Google Photos, or another cloud service, they remain there and you can download them after the reset. The same applies to documents in cloud apps like Google Drive or OneDrive.

Can I factory reset a device that is so infected it will not turn on?

Yes. On most devices, you can force a factory reset even if the operating system is not responding. On iPhone, use Recovery Mode. On Android, use Recovery Mode or bootloader mode. The exact steps depend on your device model, so search for "[your device model] factory reset without turning on" for specific instructions.

Should I factory reset if I think I have malware but I am not sure?

A factory reset is safe and will not harm your device. If you are seeing suspicious behavior — unexpected pop-ups, apps you did not install, battery draining fast — a reset is a reasonable step. Just remember to set up fresh without restoring from backup, and watch for the same symptoms to return.

Will factory reset remove spyware that someone installed on my device?

Yes, a factory reset removes spyware in the same way it removes other malware — by deleting the files and apps where the spyware lives. However, if the person who installed it still has access to your email account or your device's password, they can reinstall it after the reset. Change your passwords and enable two-factor authentication on important accounts after you reset.

Can I factory reset my device while it is connected to a computer?

You can, but it is not necessary. A factory reset happens on the device itself and does not require a computer. On some devices like iPhone, you can also reset through a computer using iTunes or Finder, but the result is the same. Disconnecting from the computer before you reset is simpler and avoids any potential interference.