What Does Corrupt File Mean?

What you need to know about corrupted files

Horizontal pixelated rainbow stripes in a JPG file, due to file corruption.
Wikimedia Commons

Corrupted files can be one of the most vexing problems users routinely face, because they often seem to come out of nowhere. On top of that, unless you know what went wrong, it can be difficult to correct the issue. This guide will give you the rundown on what data corruption means in computing, what causes it, and what you can do about it.

What is Data Corruption?

Every file has a header, sometimes called a “magic number” that tells your file system what to do with it when it's accessed. For instance, one number tells your operating system the file is an MP3 and should produce audio, while another might tell your OS it’s a Word document that should open in a word processor. If this magic number is altered, your system interprets the file as a different type than what it actually is (or was, pre-corruption).

This is compounded by the fact that certain file types expect certain numbers in certain points in the file at regular intervals. For instance, in files containing text, each character is supposed to be a certain size (with this size depending on how the text is encoded), and should start with a certain consistent combination of bytes every time. If a character’s initial bytes is changed at all, the OS might try to render an unreadable character and the file could become inaccessible.

Corruption is when the original byte composition of the file is accidentally altered. While occasionally corrupted files can still be opened, this corruption usually renders the file unable to be opened by the OS.

As every file type has its own standard, corruption can take on different forms and produce different outcomes, depending on the type of corrupted file. Media files like MP3s or password lists have a straightforward diagnoses process, while other errors that seemingly have nothing to do with corrupted data might actually have corrupted data as a root cause.

How Are Files Corrupted?

Basically, files get corrupted by some kind of electrical or mechanical malfunction.

This typically happens when a file on the hard drive has some of the bits that make it up are changed. There are a couple of cases in which this happens; the hard drive is dropped, shaken, or shifted rapidly too many times, thereby causing some of the magnetic cells to lose their ability to hold a bit. In the end, the bit of the file in that cell isn't just changed, but totally missing.

Corruption can also occur on both hard drives and solid state drives due to power failure. If you're saving a file to the hard drive as the power went out, the file can be irreparably damaged.

Modern drives try to correct this in hardware, like how hard drives have extra sectors for relocating files in case a particular sector gets damaged. Operating systems also try to address this in software using checksums to see if the data written to a file is consistent with the contents the file is supposed to have. Neither of these are foolproof, though, and enough bits are changing on enough devices at any given time that, statistically, it happens to someone somewhere often enough.

How to Prevent File and Data Corruption

Like most issues in life, the best measures are preventative. Backing up all your files in a safe place is your best bet, because it’s much easier to delete the corrupted file and copy over the uncorrupted backup than it is to try and fix the corrupted file, itself.

It’s common for devices to offer some kind of cloud backup, so if a file is corrupted, restore the file as soon as you can, especially before the corrupted file is stored in the cloud server.

There are tools for recovering corrupted files, too, although their success rate depends on the degree of corruption. Essentially, these tools analyze your files and compare the headers against the main body of the files to look for inconsistencies.

Ultimately, the appropriate remedy is very dependent on the type of corrupted file, the state of the device's hardware and software, and a myriad of other factors. Before you dig into it yourself, be sure to learn as much about the state of your device as possible, such as by reviewing log files, and look up solutions by the cause of corruption and state of your system.

Beyond that, there’s really not much you can do. Thankfully, though, file corruption is getting rarer as technology advances, and with the right precautions, you can protect yourself from it going forward.