A file extension is the suffix of a filename, conventionally used to indicate a file's format or intended association with a particular application. In a filename such as report.pdf, the extension is commonly described as .pdf, while in photo.jpg the extension is .jpg. The extension is part of the filename rather than an intrinsic component of the file's binary contents.
Operating systems and applications can use extensions as convenient hints for identifying file types, selecting default programs, displaying appropriate icons and deciding how files should be handled. The convention became especially prominent in systems where filenames were divided into a base name and a suffix, although modern operating systems generally support much more flexible filenames. An extension therefore provides useful metadata by convention, but it is not a guarantee of what the file actually contains.
Common extensions correspond to recognised formats, such as .txt for plain text, .jpg or .jpeg for JPEG images, .png for PNG images, .pdf for Portable Document Format documents, .html for HTML documents, .csv for comma-separated values and .zip for ZIP archives. Some formats use multiple suffix conventions or compound extensions, such as .tar.gz, where .tar describes a tape-archive container and .gz indicates gzip compression. The final suffix alone can therefore be insufficient to describe the complete representation.
Some applications use extensions for proprietary formats, while others use extensions that are merely conventions rather than strict technical requirements. A filename can also contain multiple dots, meaning that software must decide whether the extension is everything after the final dot or whether a recognised compound suffix should be interpreted specially.
Extensions are particularly important to graphical operating systems because they can influence file association. When a user double-clicks a document, the operating system can examine its extension and select an application configured to open that type. The same mechanism can determine icons and contextual actions. On Windows, file associations commonly rely heavily on extensions, while Unix-like systems traditionally place less reliance on them because executable permissions and file content can play a larger role.
Nevertheless, desktop applications on Linux and macOS also commonly use extensions for convenience and interoperability. File associations are configuration decisions rather than proof of file identity, so an application associated with .txt can potentially be configured to open files with that extension even if the underlying content is not valid text.
Changing a file extension does not normally convert the file. If a JPEG image named photograph.jpg is renamed to photograph.png, the bytes remain those of the JPEG unless separate software performs an actual conversion. The operating system may then attempt to treat the renamed file as PNG because of its extension, but a PNG decoder will generally reject the JPEG data. Conversely, some programs can identify files by inspecting their contents rather than trusting their names. File-type detection may use magic numbers, MIME information, filesystem metadata or application-specific signatures. This is why security software, forensic tools and operating systems can sometimes identify a file as a particular format even when its extension is missing or misleading.
Extensions can be absent, particularly on Unix-like systems where filenames do not require a conventional suffix. Executable programs, scripts and configuration files can function without extensions if the operating system and application use other mechanisms to determine how they should be interpreted. A filename such as README may be a text file, while a script named backup could be executable because its permission bits and interpreter declaration provide the necessary information. Conversely, extensions can be misleading or deliberately manipulated. Malware may use filenames such as invoice.pdf.exe in environments where the final extension determines execution behaviour, and graphical interfaces that hide known extensions can make such names harder for users to recognise. Security-conscious configurations often display complete filenames for precisely this reason.
File extensions also interact with MIME types and Internet media types, but the concepts are not identical. A MIME type such as image/png is a formal type identifier used in protocols and software interfaces, whereas .png is a filename convention. Web servers may use extensions, configured MIME mappings or other mechanisms to determine the Content-Type header sent for a resource. Applications can also use content inspection to distinguish formats.
This means that a file's extension, MIME type and actual byte structure can theoretically disagree. Robust software should not assume that a filename extension alone proves the safety or validity of a file, particularly when processing untrusted uploads. Validation may require checking the file's structure, decoding it with an appropriate parser and applying security controls appropriate to the format.
Extensions also influence portability and naming conventions. Some filesystems historically imposed restrictions on filename length or extension structure, while modern filesystems allow considerably more flexibility. Case sensitivity varies too: .TXT and .txt may be treated as equivalent by some environments but distinct by others. Some applications treat extensions case-insensitively even when the underlying filesystem does not. Compound extensions can indicate processing pipelines, such as a tar archive compressed using gzip, while extensions such as .bak, .old or .tmp may indicate a purpose rather than a formal data format. Therefore, extension terminology should be interpreted in context rather than treated as a universal technical specification.
The essential distinction is between a filename extension and a file format. A format defines how the bytes are structured and interpreted, whereas an extension is a naming convention that can communicate the expected format to people and software. A correctly named file normally uses the appropriate extension because this improves usability and interoperability, but technically sophisticated systems can identify or validate content independently. Understanding this distinction is important for file management, software development, web applications, malware analysis and data recovery. An extension is best understood as a useful hint encoded into a filename, not as an intrinsic property that transforms or conclusively identifies the underlying data.