# @xhmikosr/archive-type

> Detect the archive type of a Buffer/Uint8Array

Latest version **8.1.0** (published 2026-06-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install @xhmikosr/archive-type
pnpm add @xhmikosr/archive-type
yarn add @xhmikosr/archive-type
bun add @xhmikosr/archive-type
```

## Health

**Score 55/100 (C)** — status: active.

Positive: esm support; no vulnerabilities; high maintenance score.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 8.1.0 |
| Published | 2026-06-10 |
| First published | 2023-06-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=20 |
| Dependencies | 1 |
| Unpacked size | 4.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Kevin Mårtensson |
| Maintainers | xhmikosr |
| Keywords | 7zip, archive, buffer, bz2, bzip2, check, detect, gz, gzip, mime, pkg, rar, tar.gz, tar, zip, zst, zstd, file, type |

## Links

- npm: https://www.npmjs.com/package/@xhmikosr/archive-type
- Repository: https://github.com/XhmikosR/archive-type
- Homepage: https://github.com/XhmikosR/archive-type#readme
- Issues: https://github.com/XhmikosR/archive-type/issues
- npm.io page: https://npm.io/package/@xhmikosr/archive-type

## Dependencies (1)

- [file-type](https://npm.io/package/file-type.md) ^21.3.4

## Alternatives

- [lodash.startswith](https://npm.io/package/lodash.startswith.md) — 769.7K weekly downloads
- [@tarojs/service](https://npm.io/package/@tarojs/service.md) — 33.9K weekly downloads
- [io.extendreality.tilia.indicators.spatialtargets.unity](https://npm.io/package/io.extendreality.tilia.indicators.spatialtargets.unity.md) — 131 weekly downloads
- [@rtarojs/taro](https://npm.io/package/@rtarojs/taro.md) — 90 weekly downloads
- [node-branch-io](https://npm.io/package/node-branch-io.md) — 50 weekly downloads

## Recent versions

- 8.1.0 (latest) — 2026-06-10
- 8.0.1 — 2026-02-24
- 8.0.0 — 2026-02-24
- 7.1.0 — 2025-07-22
- 7.0.0 — 2024-04-01
- 6.0.1 — 2023-06-05
- 6.0.0 — 2023-06-05
- 5.0.0 — 2023-06-01

## README

# @xhmikosr/archive-type [![npm version](https://img.shields.io/npm/v/@xhmikosr/archive-type?logo=npm&logoColor=fff)](https://www.npmjs.com/package/@xhmikosr/archive-type) [![CI Status](https://img.shields.io/github/actions/workflow/status/XhmikosR/archive-type/ci.yml?branch=master&label=CI&logo=github)](https://github.com/XhmikosR/archive-type/actions/workflows/ci.yml?query=branch%3Amaster)

> Detect the archive type of a Buffer/Uint8Array


## Install

```sh
npm install @xhmikosr/archive-type
```


## Usage

```js
import archiveType from '@xhmikosr/archive-type';
import {readChunk} from 'read-chunk';

const buffer = await readChunk('unicorn.zip', 0, 262);

await archiveType(buffer);
//=> {ext: 'zip', mime: 'application/zip'}
```


## API

### archiveType(input)

Returns an `Object` with:

- `ext` - One of the [supported file types](#supported-file-types)
- `mime` - The [MIME type](https://en.wikipedia.org/wiki/Media_type)

Or `null` when no match.

#### input

Type: `Buffer` `Uint8Array`

It only needs the first 262 bytes.


## Supported file types

- `7z`
- `bz2`
- `gz`
- `pkg`
- `rar`
- `tar`
- `tar.gz`
- `xz`
- `zip`
- `zst`


## Related

- [archive-type-cli](https://github.com/kevva/archive-type-cli) - CLI for this module


## License

MIT © [Kevin Mårtensson](https://github.com/kevva)

---
_Source: https://npm.io/package/@xhmikosr/archive-type · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
