Detects the file type (MIME type and file extension) of a file, stream, Blob, or in-memory bytes by checking binary “magic number” signatures. Useful for identifying binary-based formats and making best-effort guesses before processing, and it does not guarantee the file is valid.
Project status
- Actively maintained: The upstream repository has recent updates, with the last push on 2026-08-15 (v22.0.2), and additional updates earlier in 2026.
- Update cadence: After the v22.0.2 update on 2026-08-15, the prior tagged update was v22.0.1 on 2026-04-09 (about 4 months gap), and v22.0.0 on 2026-03-26 (about 2 weeks before that).
AI summary generated
Recent updates
v22.0.2
v22.0.2 contains two targeted bug fixes: it improves ZIP type detection on Node.js 24 for ZIP entries that use a data descriptor, and it fixes a false positive where UTF-16 LE text could be detected as MPEG audio. The code changes also tighten and adjust MPEG header scanning logic and detection tolerances, which can change detection behavior beyond the specifically documented symptoms.
v22.0.1
Release v22.0.1 is a targeted fix aimed at bundler compatibility, specifically to prevent esbuild from resolving Node-only imports when bundling for the browser. The change is implemented in the dynamic import logic and is backed by a new esbuild-based test.
v22.0.0
v22.0.0 makes a major API and type-surface cleanup around stream handling, requiring Node.js 22 and shifting stream support to Web ReadableStreams only. It also refactors the implementation into a new internal module layout under source/, and adds new file-type detections for Apple iWork containers, while tightening parser safety limits.
BreakingFeaturesv21.3.4
v21.3.4 is described only as a general “Harden parser more” change. The code diff shows substantial hardening around AbortSignal handling and stream/tokenizer lifecycle management, including new behavior for how Node.js Readable streams and Web BYOB streams are cancelled or destroyed.
v21.3.3
v21.3.3 is described only as a general parser hardening release. The code changes show significantly more defensive handling for unknown-size inputs, plus a change in how the Node.js entrypoint opens files before tokenizing.
Securityv21.3.2
v21.3.2 ships robustness fixes focused on preventing resource exhaustion when inspecting potentially malicious files, specifically ZIP-related probing and recursive BOM/ID3 detection bounds. In the code, the ZIP fix goes further than the release notes describe by adding multiple new size and count limits plus new logic for handling ZIP data descriptors.
Securityv21.3.1
v21.3.1 is presented as a security fix for an infinite loop in the ASF parser when processing malformed input. The code diff, however, shows broader parser hardening changes, including new defensive bounds and special-case error handling during stream tokenization.
Securityv21.3.0
v21.3.0 expands Mach-O detection to support Universal (Fat) binaries and additional architectures. The core change improves Mach-O magic number handling across multiple endianness/bitness options and adds logic to disambiguate Mach-O Universal binaries from Java class files that share the same initial magic bytes.
Featuresv21.2.0
v21.2.0 adds new file type detection for SPSS (".sav") and JMP (".jmp") by matching specific magic signatures and returning the corresponding extensions and MIME types. The update also refreshes the project metadata and documentation (supported extensions/MIME types and README listings) to reflect the new formats.
Featuresv21.1.1
v21.1.1 is a small patch release focused on fixing how the library handles partial Gzip (gunzip) data during type detection. The code change adjusts stream cancellation behavior when inflation parsing fails, and a regression test was added to ensure partial gunzip input does not crash or hang.
v21.1.0
v21.1.0 extends file type detection to recognize gzip-compressed tar archives (.tar.gz), Windows registry files (.reg), and Windows registry hive files (.dat). The release notes also mention a fix for handling partially processed unzips. The code changes include additional tokenizer and detection-heuristic adjustments beyond what is explicitly documented.
Features