Computer Basics

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.

In shortThe file extension is the bit after the last dot (e.g. .jpg, .pdf, .mp4). The operating system reads that extension to decide which app opens the file, while the file’s true type is set by its first bytes (the magic number) – so renaming an extension never changes what the file actually is. Learn the 6 everyday categories and you can recognise almost any file at a glance.
2-4
Typical extension length (chars)
6
Everyday file categories
2-4
Magic-number length (bytes)
PK
First 2 bytes of every .zip

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:

What Is a File Extension? - File Types and Extensions: What They Are and How Computers Use Them
  • Where it is: everything after the last dot, e.g. holiday.jpg has the extension jpg; 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.
TipWindows hides known extensions by default. Turn them on (File Explorer > View > File name extensions) so you can always see the real ending of a file.

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:

8 File Type Categories with Formats and Sizes - File Types and Extensions: What They Are and How Computers Use Them

Documents

Text and pages you read or print: .pdf, .docx (Word), .txt, .xlsx (Excel), .pptx (PowerPoint).

Images

Pictures and graphics: .jpg (photos), .png (transparency), .webp (small, modern), .gif (animation), .svg (vector).

Audio

Sound and music: .mp3 (universal), .wav (uncompressed), .aac, .flac (lossless).

Video

Movies and clips: .mp4 (works almost everywhere), .mov (Apple), .mkv, .avi (older).

Archives

Many files squeezed into one: .zip (universal), .rar, .7z, .tar.gz (Linux).

Programs

Apps and installers that run code: .exe / .msi (Windows), .dmg (macOS), .apk (Android).

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. .docx opens 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 .desktop file names the default app.
Good to knowYou can set the default app per file type (right-click > Open with > Always). Changing the default app does not change the file, only which program launches it.

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/plain shows 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:

FF D8 FF
JPEG (.jpg)
89 50 4E 47
PNG (.png)
%PDF
PDF (.pdf)
PK
ZIP / .docx (.zip)

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.jpg to photo.png leaves 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.
Security warningTreat .exe, .msi, .bat, .scr and .apk as programs that run code – the top way malware spreads. Never open one from an unknown email or download. Watch for double extensions like invoice.pdf.exe, where the real .exe is hidden after a fake .pdf.

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:

FormatCompressionTypical Size (12 MP photo)QualityTransparencyBest Use
JPEG (.jpg)Lossy3–6 MBGood (artifacts at low quality)NoPhotos, web images
PNG (.png)Lossless15–30 MBPerfectYes (alpha)Logos, screenshots, graphics
WebP (.webp)Lossy or Lossless2–4 MB (lossy)Good to excellentYesWeb images (modern browsers)
GIF (.gif)Lossless (LZW)50 KB–2 MBLimited (256 colors)Yes (1-bit)Simple animations
AVIF (.avif)Lossy or Lossless1–3 MB (lossy)ExcellentYesNext-gen web images
RAW (.raw/.cr2)None or lossless18–36 MBMaximum (sensor data)N/AProfessional photography
Which to pickPhotos for the web: JPEG or WebP (smallest). Logos, screenshots, anything needing transparency: PNG or WebP. Simple animation: GIF. Maximum quality from a camera: RAW, then export to JPEG to share.
File Size EstimatorEstimate how much storage your photos, videos, or audio will take using typical real-world sizes
File Extension FinderType a file extension to see what kind of file it is and what opens it

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.

Nizam Ud Deen

Muhammad Nizam Ud Deen Usman is the founder of theCoreiTech and the author of The Local SEO Cosmos. Nizam works as an SEO consultant and content strategy expert with more than a decade of experience in digital marketing and IT, and he also founded ORM Digital Solutions, a digital agency serving medium and large businesses. He holds a degree from the University of Education, Lahore (Multan Campus), and was listed among the top 20 SEO experts in Pakistan in 2024. Nizam started theCoreiTech in 2012 to make computers easier to understand and use for everyone. Connect with Nizam on LinkedIn (seoobserver), X (@SEO_Observer), or at nizamuddeen.com.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button