sindresorhus/file-type

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

View on GitHub ↗Jump to charts ↓Open shareable report

Summary Information

Updated 51 minutes ago
Type:Library / SDKCategory(s):Core & Utility LibrariesLanguages & Runtimes
Added to GitGenius on September 16th, 2026
Created on April 24th, 2014
Open Issues & Pull Requests: 0 (+0)
GitHub issues: Enabled
Number of forks: 398
Total Stargazers: 4,326 (+1)
Total Subscribers: 29 (+0)

Repository Insights (GitGenius)

Median issue/PR response: 9.1 hours
Mean response time: 91.0 days
90th percentile: 312.0 days
Tracked items: 70

Most active contributors

Sign in to see contributor activity.

How this project is maintained

Work labelled "bug" is answered fastest, typically in about 2 hours, while "enhancement" waits about 4 days. Three people close 96% of everything that gets resolved.

Charts & Analytics

Fetching additional details & charts...

Issue Activity (beta)

Open issues: 0
New in 7 days: 2
Closed in 7 days: 2
Avg open age: N/A days
Stale 30+ days: 0
Stale 90+ days: 0

Recent activity

Opened in 7 days: 1
Closed in 7 days: 1
Comments in 7 days: 0
Events in 7 days: 0

Top labels

  • bug (24)
  • enhancement (18)
  • wontfix (6)
  • help wanted (5)
  • cannot reproduce (4)
  • question (3)
  • improvement (2)

Detailed Description

file-type is a utility for detecting file types by examining file contents rather than relying on extensions or MIME type declarations.

The tool solves the problem of accurately identifying what a file actually contains, which matters when you cannot trust file extensions or when you need to validate uploads. It works by reading the beginning of a file or data buffer and matching against known file signatures, also called magic numbers. This approach detects the true format regardless of what name or extension the file carries. The tool supports detection from files on disk, readable streams, and raw data buffers, making it flexible for different input sources.

Developers should choose this tool when building file upload validators, content analysis systems, or any feature where knowing the actual file type is critical for security or functionality. It suits projects that need reliable file type identification without external dependencies or system calls. The tool works with Node.js and browser environments where Uint8Array is available.

The project maintains a focused scope with regular updates to support newly discovered file formats and to address edge cases in detection logic. Maintenance activity shows consistent attention to keeping the format signatures current and the codebase aligned with evolving JavaScript standards. The tool receives ongoing refinement to handle both common and uncommon file types accurately.