Nepedia
Back to Discover
Advanced Reader
💻

File format

technology Maturity 11-13 Next article →

A file format is a specific method for encoding information so it can be stored in a computer file. It provides the rules for how data is organized. These rules can exist at many levels of abstraction. At a low level, a format describes the layout of bits and bytes. At a high level, it describes the organization of data, such as markup or tabular structures. Understanding file formats is essential because it allows different software programs to read and use the same information. Without these rules, a computer would just see a meaningless stream of data.

File formats function through various mechanisms to store different types of data. Some formats are designed for very specific purposes. For example, PNG files use lossless data compression to store bitmapped images. This means the image data is shrunk without losing any quality. Other formats act as containers for multiple types of data. The Ogg format is a great example of this. It can hold a combination of audio and video. It can also include text, such as subtitles, and metadata. Metadata is extra information about the data itself. Text files are another type, as they can contain streams of characters. These characters are organized using specific character encoding schemes.

There are different types of file formats based on how they are defined. Some are standardized, meaning the rules are official. These can be proprietary, owned by a company, or open for anyone to use. Other formats are ad hoc conventions, which are less formal. Some formats are text-based, like HTML or scalable vector graphics. These use defined syntaxes to perform specific tasks. Other formats are binary, which are not easily read by humans. Some formats even use a wrapper structure to manage complex data types within a single file.

To ensure compatibility, many formats have a published specification. A specification is a document that describes the format in detail. It may even explain how to verify if the data is correct. However, not all formats have these documents available. Some companies treat their formats as trade secrets to protect their intellectual property. In other cases, a document simply was never written. When no specification exists, developers may use reverse engineering. This involves inspecting files to figure out how they work. Developers might also pay a fee to see a specification under a non-disclosure agreement. Formats with public specifications are generally supported by more programs.

Intellectual property protection is a significant part of the history of file formats. Patent law is often used to protect the algorithms within a format. A famous example involves the GIF file format. Before 2004, using certain compression in a GIF required a patented algorithm. The patent owner eventually began collecting royalty fees. This caused a significant decrease in GIF usage. It also helped lead to the development of the PNG format as an alternative. The GIF patent expired in the United States in mid-2003. It expired worldwide in mid-2004.

Operating systems use several methods to identify a file's format. One popular method is the filename extension. This is a suffix at the end of a filename, such as .html or .gif. Many systems, including Windows and macOS, use this method. In the old FAT file system, names followed an 8.3 rule. This meant names had eight characters and extensions had only three. Because of this history, many modern extensions are still only three letters long. This can cause confusion if different formats use the same extension. It can also be a security risk. A malicious user could name a program "image.jpg.exe." If the system hides extensions, the user only sees "image.jpg."

Another method of identification is through internal metadata. A file might contain a file header at the beginning. This header provides information like the file's size, resolution, or color space. Some files also use a magic number for identification. A magic number is a small piece of data that uniquely identifies the format. For example, GIF images always start with the characters GIF87a or GIF89a. HTML files might start with the string <html. Using magic numbers is very reliable. Even if a user changes a filename, the magic number remains the same. This allows a program to verify if a file is truly the correct type or if it is corrupt.

725 words

Where will your curiosity go next?

Keep exploring at your chosen reading level.

🖼️ Images & Media (2)
Bass loop 1 (Carrai Pass).wav
Boogie riff 1.ogg
More to explore

🔬 Go deeper

More advanced topics to explore

🪜 Step back

Simpler topics to build understanding

What is Nepedia?

A free, ad-free encyclopedia for children. Every article is written at five reading levels, so the same page works for a five-year-old and a fifteen-year-old — use the level switcher above to see this one change. No account needed to read.