# attr-accept

> JavaScript implementation of the "accept" attribute for HTML5

Latest version **4.0.0** (published 2026-08-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install attr-accept
pnpm add attr-accept
yarn add attr-accept
bun add attr-accept
```

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 4.0.0 |
| Published | 2026-08-02 |
| First published | 2015-09-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >= 22 |
| Dependencies | 0 |
| Unpacked size | 16.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 120 |
| Author | Andrey Okonetchnikov @okonetchnikov |
| Maintainers | rolandjitsu |
| Keywords | accept, attr, attribute, file, html5, input, tag |

## Links

- npm: https://www.npmjs.com/package/attr-accept
- Repository: https://github.com/react-dropzone/attr-accept
- Homepage: https://github.com/react-dropzone/attr-accept#readme
- Issues: https://github.com/react-dropzone/attr-accept/issues
- npm.io page: https://npm.io/package/attr-accept

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 4.0.0 (latest) — 2026-08-02
- 3.0.0-beta.1 (beta) — 2024-11-11
- 3.0.0 — 2024-11-11
- 2.2.5 — 2024-11-07
- 2.2.4 — 2024-10-09
- 2.2.3 — 2024-10-09
- 2.2.2 — 2020-09-09
- 2.2.1 — 2020-08-08
- 2.2.0 — 2020-07-30
- 2.1.0 — 2020-03-15
- 2.0.0 — 2019-11-16
- 1.1.3 — 2018-06-18
- 1.1.2 — 2018-02-16
- 1.1.1 — 2018-02-14
- 1.1.0 — 2016-11-01
- … 4 more at https://npm.io/package/attr-accept/versions

## README

# attr-accept

> JavaScript implementation of the "accept" attribute for HTML5 `<input type="file">`

[![npm](https://img.shields.io/npm/v/attr-accept.svg?style=flat-square)](https://www.npmjs.com/package/attr-accept)
![Tests](https://img.shields.io/github/actions/workflow/status/react-dropzone/attr-accept/test.yml?branch=main&style=flat-square&label=tests)

See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#attr-accept for more information.

Ships as both ES modules and CommonJS with bundled TypeScript type definitions.

## Installation

```sh
npm install --save attr-accept
```

## Usage

```javascript
import accept from "attr-accept";

accept(
  {
    name: "my file.png",
    type: "image/png"
  },
  "image/*"
); // => true

accept(
  {
    name: "my file.json",
    type: "application/json"
  },
  "image/*"
); // => false

accept(
  {
    name: "my file.srt",
    type: ""
  },
  ".srt"
); // => true
```

You can also pass multiple mime types as a comma delimited string or array.

```javascript
accept(
  {
    name: "my file.json",
    type: "application/json"
  },
  "application/json,video/*"
); // => true

accept(
  {
    name: "my file.json",
    type: "application/json"
  },
  ["application/json", "video/*"]
); // => true
```

In a CommonJS environment, use `require` instead:

```javascript
const accept = require("attr-accept");
```

## Contributing

Checkout the organization [CONTRIBUTING.md](https://github.com/react-dropzone/.github/blob/main/CONTRIBUTING.md).

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