Join our Newsletter — 33% off our NHI Course
Home› Guides› File Types and Extensions for Beginners: Why a…
Guide Email & Communications Security

File Types and Extensions for Beginners: Why a File’s Name Can Lie About What It Is

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, under the editorial direction of Lalit Choda Updated 1 December 2026 11 min read
On this page

A file extension is the short ending of a file name, such as .pdf, that hints at the file's type.

This guide is for anyone who opens attachments or downloads and wants to know what the letters after the dot mean. You do not need any technical skill. Criminals often disguise harmful programs as harmless documents, so knowing how file names work helps you stay safe.

In short

  • The ending of a file name, such as .docx or .exe, tells your computer which app should open it.
  • The ending is only part of the name, so anyone can change it, and some computers hide it.
  • A name like invoice.pdf.exe can look like a document while really being a program.
  • Turn on file name endings, be wary of programs sent as attachments, and keep Office macro protection switched on.

What you will learn

  • Explain what a file extension is and what it does.
  • Spot a file name with a hidden or doubled ending.
  • Check that your computer shows file name endings.
  • Explain why the inside of a file matters more than its name.
File ending (extension)
the letters after the last dot in a file name, such as .pdf.
Program file (executable)
a file that runs instructions when opened, such as an .exe file on Windows.
File fingerprint (magic number)
the first few bytes inside a file that show its real type.

What is a file extension?

Think of the label on a jar in a kitchen. The label says "jam", and you usually trust it. But anyone can stick a new label on a jar, and the label does not change what is inside.

A file extension is that label. Windows describes a file name as two parts split by a dot: the name, then a short extension that "defines the file type" [1]. Extensions tell your computer which app can open the file and which icon to show [1].

Some common examples: .docx is a Word document and .pdf is a document that keeps its layout. A .zip file is a bundle of compressed files, and .exe is a program you can run [1].

Where the comparison stops working: a wrong jar label rarely causes harm. A file with a false label can run a harmful program the moment you open it.

Why does it matter?

Many attacks start with a file that pretends to be something safe. Knowing what the ending means helps you pause before you open it.

If you open email attachments

What could happen: you open what looks like a bill, and it is really a program that installs harmful software.

Check this: look at the full file name, including the last ending, before you open anything unexpected.

Next: Malicious Attachments for Beginners

If you look after a small office's computers

What could happen: staff cannot see file endings, so a disguised program looks like a document.

Check this: turn on file name endings on every computer, and keep Office macro protection at its default.

Next: Suspicious Files for Beginners

If you are new to IT or security work

What could happen: a filter that only checks the file name lets a renamed file through.

Check this: ask whether your tools check what is inside a file, not only its ending.

Next: File Upload Security for Beginners

What does it look like?

Here is a made-up folder listing, as it might look with file endings switched on.

Example only. All values are made up.

Downloads
  holiday-photo-EXAMPLE.jpg                (1)
  report-FAKE.docx                         (2)
  invoice-0000.pdf.exe                     (3)
  delivery-note-EXAMPLE.zip                (4)
  1. A picture. Image files are usually low risk to open.
  2. A normal Word document.
  3. Two endings. The last one, .exe, means this is a program, not a PDF. With endings hidden, it may show as invoice-0000.pdf.
  4. A bundle of files. You cannot see what is inside until you open it.

Why this is risky: if endings are hidden, the third file looks like a harmless invoice.

The safer way: show file endings, check the last one, and delete unexpected program files rather than opening them.

How does it work?

  1. You open a file. You double-click it in a folder or tap it in an email.
  2. The computer reads the ending. It looks at the last extension and picks the app linked to it [1]. Many endings can be opened by more than one app [1].
  3. The app reads the inside. Most file types start with a few fixed bytes, called a magic number (the first bits of a file that identify its type) [3]. A PDF file, for example, starts with the characters %PDF [2].
  4. A mismatch is a warning sign. Renaming a file changes its label, not its contents. Windows says changing an extension does not convert the file [1].
  5. Protections check the source. Windows marks files from the internet, such as downloads and email attachments, with a tag called the Mark of the Web. Office uses it to block macros in those files by default [4].
Diagram titled Why a file's name can lie about what it is. Four boxes in a row joined by arrows. Box 1, Full name: invoice.pdf.exe; two endings, the last one is the real one. Box 2, highlighted, What you see: invoice.pdf; if endings are hidden, the .exe part may not show. Box 3, Computer reads: the real ending is .exe, so it treats the file as a program. Box 4, Inside the file: the first few bytes show the true type, such as %PDF for a PDF. A note underneath says the ending is just part of the name and anyone can change it; turn on file name endings and let security tools check what is really inside.
Figure 1. The last ending decides how a file opens, and it may be hidden from view.

Criminals use this in a trick called a double extension. A program named with two endings may show only the first one. MITRE, a US research body that tracks attack methods, gives the example of a file named Evil.txt.exe showing as Evil.txt [5]. It advises turning off the Windows default that hides endings for known file types [5].

Email services also help. Outlook blocks some file types, such as .exe, from being sent or received as attachments [6].

A worked example

Sana Brandt runs a small online craft shop from home. One afternoon an email arrives from what looks like a courier. It says a parcel could not be delivered and asks her to open the attached delivery note.

The attachment is a zip file. Inside is a file that her laptop shows as delivery-note.pdf, with a document icon.

Sana pauses. She is not expecting a parcel, and a delivery note should not need to be zipped. She remembers reading that her computer might be hiding file endings.

She opens File Explorer, chooses View, then Show, then File name extensions [1]. The file name now reads delivery-note.pdf.exe. It is a program, not a document.

She thinks about what would have happened. Her computer would have read the last ending and run the file as a program. Nothing about the icon or the name she first saw would have warned her.

Sana deletes the email and the zip file without opening the program. She reports the email as phishing in her mail app. Then she checks her laptop's security app, which shows no threats found in its latest scan.

From now on, Sana keeps file endings switched on. She also tells her sister, who helps with the shop, to check the last ending on any attachment before opening it.

Myths and mistakes

What people thinkWhat is true
The icon shows what kind of file it is.The icon is picked from the ending, so it shows the label, not the contents. Check the full name.
Renaming a file changes what it is.Renaming changes only the label. The contents stay the same.
If a file says .pdf, it is a PDF.Only the last ending counts, and it may be hidden. A file can be named to look like a PDF.
Office documents are always safe.Documents can hold macros, which are small programs. Keep macros blocked for files from the internet.
A zip file is just a folder, so it is safe.A zip can hide program files. Check what is inside before opening anything in it.

What can I do this week?

  • Turn on file name endings on your computer.
  • Learn the endings that mean "program", starting with .exe on Windows.
  • Check the last ending of any unexpected attachment before you open it.
  • Leave Office's macro blocking switched on, and never click Enable on a document you did not expect.
  • Delete unexpected attachments, or ask the sender through a channel you already know.

Checklist

  • My computer shows file name endings.
  • I know that only the last ending counts.
  • I check names inside zip files before opening anything.
  • I do not open program files that arrive by email or chat.
  • I keep Office macro protection at its default.
  • I know how to report a suspicious email in my mail app.
  • Staff in my team know what a double extension looks like.

Common questions

How do I see file extensions on Windows?

Open File Explorer and choose View, then Show, then File name extensions. Every file will then show its full name, including the ending. This makes disguised programs, such as a name ending in .pdf.exe, much easier to spot before you open them.

Which file endings are most risky?

Endings that run instructions carry the most risk, such as .exe on Windows, scripts and shortcut files. Office files that can hold macros are another concern. The practitioner guide on risky file types lists the main families and how organisations block them.

Can I make a file safe by changing its ending?

No. Changing the ending only changes the label, not the contents. A program renamed to .txt is still a program inside, and other tools may still treat it as one. The only safe choice for an unexpected program file is not to open it.

What is a magic number in a file?

A magic number is a short pattern of bytes at the very start of a file that identifies its type. A PDF starts with the characters %PDF, for example. Security tools can compare this with the ending to spot files that are pretending to be something else.

Does this matter on a Mac or phone?

Yes, the idea is the same. Every system uses file types to decide how to open things, and every system can be tricked by a misleading name. The endings differ, but the habit of checking the full name and the sender works everywhere.

Where next?

Ready for the detail? Read the practitioner guide: Risky File Types. It goes further into the riskiest file families, how email and browser filters block them, and how the Mark of the Web can be lost.

Also useful:

Related NHI Mgmt Group resources: PDF Files for Beginners, File Upload Security for Beginners and Verifying Software Downloads for Beginners.

Key terms

File extension
The letters after the last dot in a file name, which tell the computer what kind of file it is.
Double extension
A naming trick that puts a harmless-looking ending before the real one, such as .pdf.exe.
File extension mismatch
When a file's ending does not match what is really inside it.
Magic number
The first few bytes of a file, which show its real type.
Macro-enabled document
An Office file that can run small programs, called macros, when opened.
Malware
Software made to cause harm, such as stealing data or locking files.

Sources and further reading

  1. Microsoft Support, "Common file name extensions in Windows". https://support.microsoft.com/en-gb/help/4479981/windows-10-common-file-name-extensions (accessed 1 Dec 2026).
  2. Library of Congress, "PDF (Portable Document Format) Family", Sustainability of Digital Formats, fdd000030. https://www.loc.gov/preservation/digital/formats/fdd/fdd000030.shtml (accessed 1 Dec 2026).
  3. Library of Congress, "Explanation of format description terms", Sustainability of Digital Formats. https://www.loc.gov/preservation/digital/formats/fdd/fdd_explanation.shtml (accessed 1 Dec 2026).
  4. Microsoft Learn, "Macros from the internet are blocked by default in Office", updated July 2026. https://learn.microsoft.com/en-us/microsoft-365-apps/security/internet-macros-blocked (accessed 1 Dec 2026).
  5. MITRE ATT&CK, "Masquerading: Double File Extension" (T1036.007). https://attack.mitre.org/techniques/T1036/007/ (accessed 1 Dec 2026).
  6. Microsoft Support, "Blocked attachments in Outlook". https://support.microsoft.com/en-us/office/blocked-attachments-in-outlook-434752e1-02d3-4e90-9124-8b81e49a8519 (accessed 1 Dec 2026).

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick both boxes to continue.