# badgen

> Fast svg badge generator.

Latest version **3.3.2** (published 2026-05-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install badgen
pnpm add badgen
yarn add badgen
bun add badgen
```

## Health

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

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

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 3.3.2 |
| Published | 2026-05-10 |
| First published | 2018-06-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 215.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 560 |
| Author | Amio |
| Maintainers | amio |

## Links

- npm: https://www.npmjs.com/package/badgen
- Repository: https://github.com/badgen/badgen
- Homepage: https://github.com/badgen/badgen#readme
- Issues: https://github.com/badgen/badgen/issues
- npm.io page: https://npm.io/package/badgen

## Recent versions

- 3.3.2 (latest) — 2026-05-10
- 3.3.1 — 2026-05-08
- 3.2.3 — 2023-07-21
- 3.2.2 — 2020-11-30
- 3.2.1 — 2020-07-07
- 3.2.0 — 2020-07-06
- 3.1.0 — 2020-05-09
- 3.0.1 — 2019-10-22
- 3.0.0 — 2019-10-04
- 2.8.2 — 2019-07-06
- 2.8.1 — 2019-07-06
- 2.8.0 — 2019-07-06
- 2.7.1 — 2019-03-25
- 2.7.0 — 2019-01-29
- 2.6.0 — 2019-01-02
- … 32 more at https://npm.io/package/badgen/versions

## README

# badgen

[![npm version][npm-src]][npm-href]
[![Coverage Status][coveralls-src]][coveralls-href]
[![Bundle size][bundlephobia-src]][bundlephobia-href]
[![License][license-src]][license-href]

Fast handcraft svg badge generator. Used on [badgen.net](https://badgen.net).

- 🌀 Zero dependency
- ⚡️ Fast by design (see [benchmarks](#benchmarks))
- 👯‍ Running in node & browser

## Usage

`npm install badgen`

```javascript
const { badgen } = require('badgen')

// only `status` is required.
const svgString = badgen({
  label: 'npm',      // <Text>
  labelColor: 'ADF', // <Color RGB> or <Color Name> (default: '555')
  status: 'v1.2.3',  // <Text>, required
  color: 'blue',     // <Color RGB> or <Color Name> (default: 'blue')
  style: 'flat',     // 'flat' or 'classic' (default: 'classic')
  icon: 'data:image/svg+xml;base64,...', // Use icon (default: undefined)
  iconWidth: 13,     // Set this if icon is not square (default: 13)
  scale: 1           // Set badge scale (default: 1)
})
```

```javascript
import { badgen } from 'badgen'
```

Available color names:

![](https://badgen.net/badge/color/blue/blue)
![](https://badgen.net/badge/color/cyan/cyan)
![](https://badgen.net/badge/color/green/green)
![](https://badgen.net/badge/color/yellow/yellow)
![](https://badgen.net/badge/color/orange/orange)
![](https://badgen.net/badge/color/red/red)
![](https://badgen.net/badge/color/pink/pink)
![](https://badgen.net/badge/color/purple/purple)
![](https://badgen.net/badge/color/grey/grey)
![](https://badgen.net/badge/color/black/black)

### In browser

```html
<script src="https://unpkg.com/badgen"></script>
<script>
  var svgString = badgen({ /*...*/ })
</script>
```

## Benchmarks

`npm run bench` on iMac 5K (Late 2014), 3.5G i5, with Node.js 12.11.0:

```bash
[classic] style, long params x 985,898 ops/sec ±0.37% (94 runs sampled)
[classic] style, full params x 1,284,886 ops/sec ±0.42% (95 runs sampled)
[classic] style, with emoji  x 1,291,768 ops/sec ±0.28% (95 runs sampled)
[classic] style, with icon   x 1,177,120 ops/sec ±0.94% (95 runs sampled)
   [flat] style, long params x 780,504 ops/sec ±0.39% (94 runs sampled)
   [flat] style, full params x 1,012,111 ops/sec ±0.40% (97 runs sampled)
   [flat] style, with emoji  x 1,013,695 ops/sec ±0.91% (95 runs sampled)
   [flat] style, with icon   x 994,481 ops/sec ±0.30% (94 runs sampled)
```

## Development

- `npm test` builds `dist/` and runs the suite with Node's native test runner.
- `npm run snaptests` updates the checked-in snapshots.
- `npm run preview` starts the Vite preview app with live reload at `http://localhost:5173/`.

## See Also

- [gradient-badge][gradient-badge] - Badge generator with color gradient support

[npm-src]: https://badgen.net/npm/v/badgen
[npm-href]: https://www.npmjs.com/package/badgen
[bundlephobia-src]: https://badgen.net/bundlephobia/minzip/badgen
[bundlephobia-href]: https://bundlephobia.com/result?p=badgen
[coveralls-src]: https://badgen.net/coveralls/c/github/amio/badgen/master
[coveralls-href]: https://coveralls.io/github/amio/badgen?branch=master
[license-src]: https://badgen.net/github/license/amio/badgen
[license-href]: LICENSE.md
[gradient-badge]: https://github.com/bokub/gradient-badge

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