sindresorhus

file-type

Detect the file type of a file, stream, or data

by sindresorhus

JavaScript

JavaScript93.6%
PostScript5.6%
TypeScript0.8%
Rich Text Format0.1%

Commit activity

Last 12 weeks · 17 commits

Full graph →

Community health

5 of 6 standards met

Community profile →
100
✓README✓License✓Contributing✓Code of Conduct○Issue Template✓PR Template
sevmonster

Description In #768, was changed to following an RFC draft. However, that draft has not entered a standard track, let alone exit its draft state, and it was created in 2019. It's still being updated, so it may eventually become standard, but until that time it would be best to maintain for compatibility. GitHub search shows exceedingly low support for , while the traditional shows overwhelming use. Existing Issue Check [x] I have searched the existing issues and could not find any related to my problem. File-Type Scope Acknowledgment [x] I understand that file-type detects binary file types and not text or other formats.

sevmonster · 6d ago
Borewit

Lets applications bound read-buffer allocations driven by untrusted file content, helping prevent excessive memory allocation (CWE-789) while preserving custom-detector compatibility by default. Exposes the opt-in limit introduced in strtok3 v10.4.0 for read-buffer allocations and stream lookahead, defaulting to . Rejects oversized requests with , preserving the fallback during gzip content probing. Resolves the custom-detector compatibility issue caused by sharing ZIP’s 1 MiB allocation limit, keeping the two limits independent.

Borewit · 1w ago
Borewit

Update to and use its configurable decompression limit when inspecting ZIP metadata entries. Decompression size checks, cancellation, and trailing-data recovery now live in @tokenizer/inflate, allowing file-type to remove its own decompression implementation. File-type retains its ZIP iteration override to enforce archive-wide scanning budgets, entry-count limits, and descriptor-size validation without changing the dependency’s behavior for other consumers. Handle entries that exceed the limits gracefully and preserve detection when a ZIP data descriptor is incomplete or has no signature. The upstream inflater recovers decompressed metadata when descriptor bytes remain after the deflate stream. Resolves Borewit/tokenizer-inflate#165 Related to https://github.com/Borewit/tokenizer-inflate/pull/213 #807

Borewit · 1w ago
Structured data for AI agents

Repository: sindresorhus/file-type. Description: Detect the file type of a file, stream, or data Stars: 4338, Forks: 398. Primary language: JavaScript. Languages: JavaScript (93.6%), PostScript (5.6%), TypeScript (0.8%), Rich Text Format (0.1%). License: MIT. Topics: buffer, detect, file, file-types, javascript, magic, magic-numbers, nodejs, uint8array. Latest release: v22.2.0 (1w ago). Open PRs: 0, open issues: 0. Last activity: 1w ago. Community health: 100%. Top contributors: sindresorhus, Borewit, kevva, mifi, karlhiramoto, sly7-7, stroncium, mceachen, junmer, Richienb and others.