h2non/filetype
Fast, dependency-free Go package to infer binary file types based on the magic numbers header signature observed · 2026-08-28
Health v2 · maintenance only
63/100
- Activity 90
- Release rhythm 8
- Longevity 100
How is this computed?
round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10) — computed 2026-09-03. Adoption (stars, forks) is never an input.
- gap_med: n/a
- age_days: 3996
- days_rel: n/a
- days_push: 63
- n_releases_24m: 0
Adoption not part of the score
2297 stars · 190 forks observed · 2026-08-28
What it is AI-extracted, prompt v1, taxonomy v1, 2026-08-30, confidence not recorded
A small, dependency-free Go library that infers file and MIME types by checking binary magic number signatures. It supports a wide range of file types, requires only the first 262 bytes of a file, and allows pluggable custom matchers.
Use cases
- detect the real file type of an uploaded file regardless of its extension
- get the MIME type from a binary file header in Go
- check if a file is an image, video, or audio by its content
- validate that uploaded files match their claimed extension
- identify file types from just the first bytes of a stream
When to choose
- you need fast, dependency-free file type detection in Go
- you only have access to a file header or byte slice, not the full file
- you want to validate uploads by content rather than trusting extensions or client-supplied MIME types
When to avoid
- you need to detect text-based formats like SVG (use go-is-svg instead)
- you need deep content inspection beyond the file header
- you are not working in Go
Facets
library · maturity stable
parser developer-tools files developer-tools go cross-platform magic-numbers mime-type file-type-detection file-validation
4 sources
- readme: https://github.com/h2non/filetype · fetched 2026-08-28 · c8b06de5cf77
- homepage: https://pkg.go.dev/github.com/h2non/filetype?tab=doc · fetched 2026-08-29 · 2528be53c308
- site_page: https://pkg.go.dev/about · fetched 2026-08-29 · 757852027879
- site_page: https://go.dev/project · fetched 2026-08-29 · d5ca00bb378b
Member repositories
| Repository | Role | Health v2 |
|---|---|---|
| h2non/filetype | main | 63 |
For agents
Data as of 2026-08-30T08:39:29.467469+00:00 · Report a problem