File Types and Extensions: What They Are and How Computers Use Them
A file extension is the short label after the last dot in a filename, like the docx in report.docx. It tells your operating system which program should open the file. A file type is the actual format of the data inside, and the two do not always match, which is why renaming a file does not convert it.
What Is a File Extension?
A file extension is the few characters after the final dot in a filename, and the operating system uses it to pick the default program:

- Where it is: everything after the last dot, e.g.
holiday.jpghas the extensionjpg; usually 2-4 characters. - What it does: the OS keeps a list mapping each extension to an app, so double-clicking opens it in the right program.
- It is only a label: the extension does not change the data inside the file, it just names the format.
What Are the Main File Type Categories?
Almost every file you meet falls into one of six everyday categories, each with a few common extensions:

Documents
Images
Audio
Video
Archives
Programs
Best for: knowing the category tells you what an unfamiliar file is for, even before you open it. Code files (.py, .js, .html) and data files (.csv, .json) are two extra categories developers see often.
How Does the Operating System Know Which App to Open?
The operating system follows a simple chain: file extension, to a MIME type, to a default app:
- Windows: stores extension-to-program links in the registry, keyed by the extension (e.g.
.docxopens Word). - macOS: uses Uniform Type Identifiers (UTIs) plus the extension to choose the right app.
- Linux: uses MIME types from a shared database, and a
.desktopfile names the default app.
What Are MIME Types?
A MIME type is a standard name for a file’s format used on the web and in email, written as type/subtype (for example image/jpeg):
- HTML file: text/html
- JPEG image: image/jpeg
- MP4 video: video/mp4
- JSON data: application/json
- PDF document: application/pdf
- Why it exists: a download or email has no filesystem, so the MIME type travels in the HTTP/email header to declare the format.
- Independent of the name: MIME works even if the filename has no extension at all.
- Get it wrong and a browser misreads the file – a JavaScript file sent as
text/plainshows as source code instead of running.
How Do Computers Really Identify a File? (Magic Numbers)
Underneath the extension, most files start with a fixed signature called a magic number that reveals their true type:
- What it is: the first 2-4 bytes of a file, a fixed pattern that identifies the format no matter what the filename says.
- Why it is trusted: renaming a file does not change its bytes, so the signature is more reliable than the extension.
- Who uses it: professional apps, browsers, and antivirus read the header, not just the extension, to know what a file really is.
Best for: understanding why a renamed file can still be detected. Here are signatures for files you handle every day:
What Happens When You Change a File Extension?
Changing an extension only renames the file, it does not convert the data inside:
- No conversion: renaming
photo.jpgtophoto.pngleaves it a JPEG; it is still JPEG bytes with a misleading name. - Open errors: apps that trust the extension may fail or show errors; apps that read the magic number still open it correctly.
- To truly convert, open the file and export or Save As the target format, which rewrites the data.
Image Format Comparison: Size, Quality, and Transparency
Image formats trade file size against quality and transparency support; this table compares the common ones on a 12-megapixel photo:
| Format | Compression | Typical Size (12 MP photo) | Quality | Transparency | Best Use |
|---|---|---|---|---|---|
| JPEG (.jpg) | Lossy | 3–6 MB | Good (artifacts at low quality) | No | Photos, web images |
| PNG (.png) | Lossless | 15–30 MB | Perfect | Yes (alpha) | Logos, screenshots, graphics |
| WebP (.webp) | Lossy or Lossless | 2–4 MB (lossy) | Good to excellent | Yes | Web images (modern browsers) |
| GIF (.gif) | Lossless (LZW) | 50 KB–2 MB | Limited (256 colors) | Yes (1-bit) | Simple animations |
| AVIF (.avif) | Lossy or Lossless | 1–3 MB (lossy) | Excellent | Yes | Next-gen web images |
| RAW (.raw/.cr2) | None or lossless | 18–36 MB | Maximum (sensor data) | N/A | Professional photography |
Last Thoughts on File Types and Extensions
File types and extensions are how your computer, browser, and apps decide what a file is and which program should handle it. Remember the split: the extension is a human-readable label the operating system uses for convenience, while the magic number inside the file sets its true format. Knowing the six everyday categories and that renaming never converts a file will save you from the most common file-handling mistakes.
Key Takeaways:
- A file extension is the label after the last dot; a file type is the actual format of the data inside.
- The operating system maps extension, to MIME type, to a default app to decide what opens a file.
- Magic numbers (the first 2-4 bytes) identify a file’s true type, which is why antivirus and pro apps trust them over the extension.
- Renaming an extension never converts a file – to change format you must export or Save As.
- The six everyday categories are documents, images, audio, video, archives, and programs.
- Treat .exe, .msi and similar program files as risky from unknown sources, and watch for hidden double extensions.
Frequently Asked Questions (FAQs)
What is the difference between a file type and a file extension?
A file type is the actual internal format of the data. A file extension is a filename suffix that signals the type. Extensions can be changed or omitted — the actual file type is determined by the internal header bytes (magic number), not the extension.
What happens if you rename a .exe file to .txt?
The file’s internal data does not change. A text editor attempting to open it will display garbled binary characters. The OS will no longer run it by double-clicking, but the file remains a valid executable and security tools will identify it by its PE header.
Is PNG or JPEG better for web images?
JPEG is better for photographs — 3–6 MB vs PNG’s 15–30 MB at equivalent pixel dimensions. PNG is better for logos and graphics with transparency. WebP is best overall: 25–35% smaller than JPEG with transparency support.
What is a MIME type?
A MIME type is a standardized string that identifies a file’s format in HTTP and email headers, formatted as type/subtype (e.g., image/jpeg, application/json). It operates independently of the filename extension to ensure correct content handling.
Which archive format compresses files the most?
7z typically achieves the best compression ratio using LZMA2, producing archives 30–50% smaller than ZIP for most file types. RAR also outperforms ZIP. The best format depends on file type — already-compressed files (JPEG, MP4) gain little from any archive format.


