Compression Detector

Instantly identify file compression formats using our compression detector. Analyze magic bytes and entropy to verify GZIP, ZIP, RAR, 7Z, and TAR archives today.

xDevToolsInitializing Tool

Related Utilities

Last Updated: August 14, 2026|Author: Yogeesh S, Senior Software Engineer

The Mathematical Foundation of File Entropy in a Compression Detector

At the core of identifying binary data lies the concept of Shannon entropy, a measure of unpredictability within a data stream. A reliable compression detector relies on this mathematical principle to differentiate between high-density compressed files and raw, uncompressed binary data. When data is compressed, the frequency distribution of bytes tends toward uniformity, resulting in higher entropy values, typically nearing the theoretical maximum of 8 bits per byte.

$$H(X) = - \sum_{i=0}^{255} P(x_i) \log_2 P(x_i)$$

In this equation, $P(x_i)$ represents the probability of a specific byte value appearing in the file. Files with high entropy—usually exceeding 7.5 bits—are statistically likely to be compressed or encrypted. Our compression detector calculates this value to provide a confidence interval for files that lack standard recognizable signatures.

Why Magic Bytes Matter for Your Compression Identifier

While entropy provides a probabilistic guess, "magic bytes" provide certainty. These are specific sequences of bytes located at the beginning of a file, acting as a unique fingerprint for a specific format. A reliable compression identifier scans the initial 8 bytes of a file against known signatures to determine its structure instantly.

For instance, a GZIP file always starts with the hex sequence 1F 8B, while a 7-Zip archive begins with the unmistakable 37 7A BC AF 27 1C. By comparing these headers against a pre-defined catalog, the tool performs a deterministic identification that bypasses the need for complex, time-consuming decompression. This method is the industry standard for file type validation in systems programming.

Signature Comparison Table for Common Archive Formats

To effectively utilize this compression detector, it is helpful to understand the hex signatures it looks for during file analysis. The following table maps common archive formats to their defining magic bytes.

FormatMagic Bytes (Hex)Reliability
GZIP1F 8BHigh
ZIP50 4B 03 04High
Bzip242 5A 68High
RAR52 61 72 21High
7-Zip37 7A BC AF 27 1CHigh
Zlib78 01, 78 9C, 78 DAModerate
TAR75 73 74 61 72 (at offset 257)Moderate

Configuring Your Compression Detector Inputs

Before running an analysis, you must select the appropriate input mode to match your data source. The tool supports three distinct methods, each optimized for different workflows.

  • Hex Mode: Best for raw binary analysis where you have copied the header dump from a hex editor. Ensure your input is stripped of 0x prefixes for accurate parsing.
  • Base64 Mode: Ideal for scenarios where the file content has been encoded into a string format, commonly found in JSON payloads or API responses.
  • File Mode: The most convenient option for local file verification. This mode reads the raw bytes directly from your disk, ensuring no data modification occurs before the scan.

Verifying File Integrity with the Compression Identifier

Sometimes a file extension might be misleading, or a download could be corrupted. The verification feature allows you to input an expected format name—such as "zip" or "gzip"—to confirm that the underlying magic bytes actually match the file's designation. If the compression detector finds a mismatch, it indicates that the file may be mislabeled, truncated, or potentially malicious.

BEFORE (INPUT)
50 4B 03 04 0A 00 00 00
AFTER (OUTPUT)
ZIP Archive (.zip)
Confidence: 99%

Step-by-Step Analysis with the Compression Detector

Follow these steps to identify your archive type using the interface provided.

1

Select Input Mode

Choose between "hex", "base64", or "file" based on the data you possess.

2

Provide Data

Paste your raw hex or base64 string, or use the "Choose File" button to upload your target document.

3

Review Identification

Examine the "Compression Identification" panel to see the primary guess, the detected magic header, and the calculated entropy level.

4

Validate Expectations

Type your expected format into the "Verify expected format" field and click "Match Expected Format" to confirm the signature match.

Interpreting Entropy Results for Unknown Binary Files

When a file lacks a standard magic header, the compression detector falls back to its entropy analysis. An entropy value between 7.5 and 8.0 suggests the file is either highly compressed or encrypted. If the value is substantially lower, the file is likely a raw binary or text document. Understanding these thresholds is critical when dealing with proprietary or non-standard file formats that do not follow traditional archive signatures.

Quick Reference: Compression Identifier Data Handling

  • Header Matching: The tool scans the first 8 bytes of the data block to confirm format identity.
  • Entropy Calculation: Computed across the entire data stream to differentiate between compressed and uncompressed content.
  • TAR Detection: Unlike other formats, the tool specifically checks for the "ustar" string at the 257-byte offset, acknowledging the unique structure of POSIX-compliant tarballs.
  • Signature Sorting: Results are presented based on confidence percentages, with 99% indicating a perfect magic byte match.

Why does the compression detector sometimes report "Highly Compressed / Encrypted Binary"?

This occurs when the tool cannot find a specific header match, but the byte entropy is high enough (over 7.5) to suggest that the data has been processed by a compression or encryption algorithm.

How does the tool determine the confidence percentage?

Confidence is derived from the presence of known magic bytes; a match with a defined header yields a 99% confidence, while entropy-based guesses are assigned lower probabilities.

What should I do if my ZIP file is not detected?

Check if the file is corrupted or truncated at the beginning, as the tool relies on the first four bytes (50 4B 03 04) to identify standard ZIP archives.

Which input format is the most accurate for this compression identifier?

The "file" input mode is the most accurate because it reads raw bytes directly, avoiding potential encoding issues associated with hex or base64 text strings.

Can this tool identify encrypted archives?

It can identify if an archive is highly compressed (which often looks like high entropy), but it cannot decrypt the contents or verify encryption keys.

What's the difference between the Zlib and GZIP signatures?

While both use compression, GZIP adds a specific header (1F 8B) and metadata, whereas Zlib streams start with specific markers like 78 01 or 78 9C.

How does the tool handle very small files?

The tool analyzes all provided bytes, but signatures require a minimum length; if a file is smaller than the required header length, detection may be inconclusive.

When should I rely on the entropy score?

Rely on the entropy score only when the "Matched Signatures" section returns no results or low-confidence guesses for an unknown binary format.