Why Can Two Files Look Identical but Have Different Sizes?

Introduction

Two files can look identical—same name, same visible content, even the same preview—yet report different sizes. This is a common source of confusion for anyone who manages digital files. The answer lies in how files are stored, represented, and measured by operating systems and applications.

Quick answer: why identical-looking files have different sizes

Files that appear the same can have different sizes because “size” can mean several different things and because storage systems add, compress, or represent data in different ways. Factors include file metadata, encoding differences, compression, sparse files, storage block allocation, hidden or embedded data, and differing measurement units or reporting methods used by operating systems and programs.

What “file size” actually means

Before exploring causes, it helps to understand the common measurements you’ll see.

Logical size (or byte count): the number of bytes of actual data inside the file as defined by the file format or application. For example, a plain text file that contains 1,000 characters usually has about 1,000 bytes (depending on encoding).

Allocated size (or disk usage): how much space the file consumes on a storage device. This depends on the device’s block size (allocation unit) and whether the file uses contiguous blocks or sparse allocation.

App-reported size: some applications report compressed or uncompressed size depending on context (for example, archive managers may show both).

Common reasons files that look identical differ in size

Here are the typical causes, each explained with a practical example.

1. Different file encodings and line endings

Text files are a frequent source of confusion. A file saved in UTF-8 encoding can be a different size than the same text saved in UTF-16, UTF-32, or a legacy single-byte encoding. Non-ASCII characters (accented letters, emojis) take more bytes in some encodings.

Line endings differ between operating systems: Windows uses a carriage return and line feed pair (CR+LF, two bytes) while Linux and macOS use a single line feed (LF, one byte). A text file with many lines can therefore have a noticeably different byte count when moved between systems or edited in different editors.

2. Hidden metadata and extended attributes

Files often carry metadata—information about the file rather than the file content. Metadata can include timestamps, author information, permissions, thumbnails, or custom application notes.

Some metadata is stored in the file itself (for instance, EXIF data in a JPEG image contains camera settings and a small thumbnail). Other metadata is stored by the filesystem as extended attributes (xattr on macOS/Linux, NTFS alternate data streams on Windows). Two copies that look identical in an image viewer might differ in overall file size because one copy retained metadata while the other did not.

3. Compression and different file formats

Many file types support internal compression (for instance, PNG images, ZIP archives, or modern Office documents). The same image saved with different compression settings—lossless vs lossy, different quality settings, or different compression algorithms—will look visually similar but have different file sizes.

Also, container formats differ. Saving a document as PDF versus DOCX or exporting an image as JPEG vs PNG can produce different sizes even if the visual appearance is close.

4. Sparse files and block allocation

A sparse file is a file that contains long ranges of zeroes that the filesystem records as empty space rather than physically storing those zero bytes. Sparse files are common in virtual machine disk images and some database files.

Logical size might be large (for example, a 20 GB virtual disk), but the allocated size on disk can be much smaller because empty ranges are not stored. If one copy of a file is sparse-aware and the other is a fully expanded copy, they will report different allocated sizes.

5. Filesystem allocation units and fragmentation

Hard drives and SSDs store data in blocks or clusters. If a filesystem uses a 4 KB allocation unit, a 1-byte file still consumes 4 KB of disk space. Two files with similar logical sizes can have different allocated sizes depending on how their data lay across allocation boundaries and whether the file is fragmented.

Example: a 1,001-byte file might occupy three blocks if fragmentation places pieces across block boundaries, while a contiguous copy might use only two blocks.

6. Embedded thumbnails, previews, or indexes

Some applications embed thumbnails or search index data inside files. Photo management software, for example, might add or update embedded previews in images so the same visible image file can grow or shrink depending on whether those previews are present.

Similarly, email files or document management systems sometimes append indexing information or previews that change the file size without altering what you see when opening the document in a reader.

7. Differences introduced by transfer methods

How a file is copied or transferred can change its size. Transferring over FTP in ASCII mode can convert line endings, altering the byte count. Some cloud sync tools compress files during transit or intentionally strip metadata for privacy, so the stored copy can be smaller or larger than the original.

Also, some copy tools expand sparse files into fully allocated files during copying, increasing the allocated size while keeping content logically the same.

8. Encryption and checksums

Encrypting a file usually changes its size slightly because encryption may include padding or headers. For example, an encrypted container might store an initialization vector or block alignment padding, so an encrypted copy of the same visible data is a few bytes larger.

Similarly, archives that include checksums or integrity blocks add extra bytes to hold that information.

9. File headers, version differences, and application-specific wrappers

Many formats include headers—small chunks of metadata and format instructions at the start of the file. Different program versions can write different header data. A PDF saved by one application may include additional compatibility information that makes it larger than a PDF produced by another program even if the visible document pages are identical.

How to tell which kind of “size” you’re seeing

Operating systems and tools use different terms. Knowing which number you look at helps diagnose differences.

In Windows File Explorer you’ll see “Size” (logical bytes) and “Size on disk” (allocated). On macOS Finder you’ll typically see logical size; Get Info shows allocation in some cases. Linux tools: ls -l shows logical size, du shows used disk space (allocated size).

Practical steps to compare seemingly identical files

Here are methods to check why files differ.

Check byte-by-byte equality: use tools such as fc (Windows), cmp or diff (Linux/macOS) to verify whether the files’ data are identical. If they differ, the tools will show where.

Check checksums: produce cryptographic hashes (md5sum, sha256sum) for both files. If hashes match, the files are byte-identical; differences in reported size are likely due to allocation or reporting differences.

Compare metadata: view image EXIF data (exiftool), view document properties, or inspect extended attributes (getfattr, xattr). Differences here explain size variations.

Inspect archive content: if the files are compressed containers (ZIP, DOCX, APK), open them with an archive manager to see contained files and manifest differences.

Check disk usage: use du to see actual disk blocks used. If logical size is the same but disk usage differs, allocation or sparsity is the cause.

Concrete examples

Example 1 — Two identical-looking JPG photos: One saved from a phone includes EXIF data and a thumbnail plus GPS coordinates; the other was exported without metadata. The first reports 3.2 MB, the second 2.8 MB.

Example 2 — Text files from different OS: A log file created on Windows and then opened on Linux may differ by several kilobytes because CR+LF sequences were converted to LF only.

Example 3 — Virtual disk images: A virtual machine’s disk file reports a logical size of 40 GB but a du command shows 6 GB used because most of the disk sectors are unallocated and stored as a sparse file. If you copy the file to a filesystem that doesn’t support sparse files, the copy may expand to the full 40 GB.

When differences matter

Understanding these differences matters in several contexts.

Backup and storage planning: allocated size determines how much actual disk space you need. Backups that expand sparse files can use far more storage than expected.

Data transfer and bandwidth: compressed or stripped files save bandwidth; encrypted or padded files cost a little extra.

Version control and deduplication: systems that deduplicate based on content hashes will treat byte-identical files the same, even if metadata differs. But systems that deduplicate based on allocated blocks might not.

Privacy and compliance: metadata can reveal sensitive information (e.g., GPS coordinates). Two “identical” documents might differ because one retains private metadata.

Tips to make file sizes predictable

If you want consistent file sizes across copies or systems, consider these steps.

Strip metadata when unnecessary: many tools (image editors, document export options, or exiftool) can remove embedded metadata.

Choose consistent encoding and line endings: save text files in UTF-8 and normalize line endings with a tool (dos2unix or editor settings).

Use standard save/export options: export images or documents with explicit compression or quality settings rather than relying on default application behavior.

Be aware of filesystem features: when copying large sparse files, use tools that preserve sparsity (cp –sparse=always on Linux, specific virtual disk copy tools for VM images).

Summary of key distinctions

Logical size vs allocated size: logical size is the file’s byte count; allocated size is how much disk space it uses.

Content vs metadata: visible content may be identical, while embedded or filesystem metadata causes differences.

Format and compression: internal compression or encoding choices change size without necessarily changing appearance.

Transfer and storage behavior: copying, encryption, and filesystem features can add or remove bytes.

Conclusion

Files that look identical can report different sizes for many practical reasons: encoding and line endings, metadata, internal compression, sparse allocation, filesystem block sizes, and even how a copy was made. Knowing whether you’re looking at logical size or allocated size, and using the right inspection tools, will help you understand and control these differences for storage planning, data transfers, privacy, and troubleshooting.