# dnd5e-dice-roller

> Rolls dice according to RPG dice notation (e.g. 1d4, d6, 2d6+5, 1d20-1)

Latest version **0.0.15** (published 2025-11-11) · ISC license · 0 weekly downloads

## Install

```sh
npm install dnd5e-dice-roller
pnpm add dnd5e-dice-roller
yarn add dnd5e-dice-roller
bun add dnd5e-dice-roller
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.0.15 |
| Published | 2025-11-11 |
| First published | 2021-12-02 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 22.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | mitchb09 |
| Maintainers | mitchb09 |
| Keywords | dnd5e-dice-roller, dice, die, rpg, roll, d&d, dnd, diceroll |

## Links

- npm: https://www.npmjs.com/package/dnd5e-dice-roller
- npm.io page: https://npm.io/package/dnd5e-dice-roller

## Dependencies (1)

- [dnd5e-dice-roller](https://npm.io/package/dnd5e-dice-roller.md) file:

## Alternatives

- [@sentry/react-native](https://npm.io/package/@sentry/react-native.md) — 2.6M weekly downloads
- [@ardatan/aggregate-error](https://npm.io/package/@ardatan/aggregate-error.md) — 708.1K weekly downloads
- [custom-error-generator](https://npm.io/package/custom-error-generator.md) — 2.0K weekly downloads
- [@technik-sde/prosemirror-recreate-transform](https://npm.io/package/@technik-sde/prosemirror-recreate-transform.md) — 1.5K weekly downloads
- [@suchipi/error-utils](https://npm.io/package/@suchipi/error-utils.md) — 78 weekly downloads

## Recent versions

- 0.0.15 (latest) — 2025-11-11
- 0.0.14 — 2025-01-16
- 0.0.13 — 2023-05-03
- 0.0.12 — 2023-05-03
- 0.0.11 — 2022-11-29
- 0.0.10 — 2022-10-21
- 0.0.9 — 2022-10-21
- 0.0.8 — 2021-12-02
- 0.0.7 — 2021-12-02
- 0.0.6 — 2021-12-02
- 0.0.5 — 2021-12-02
- 0.0.4 — 2021-12-02
- 0.0.3 — 2021-12-02
- 0.0.2 — 2021-12-02
- 0.0.1 — 2021-12-02

## README

# dnd5e-dice-roller

[![npm](https://img.shields.io/badge/npm-dnd5e--dice--roller-green?style=flat-square)](https://www.npmjs.com/package/dnd5e-dice-roller)
[![Version](https://img.shields.io/npm/v/dnd5e-dice-roller?label=version&style=flat-square)](https://www.npmjs.com/package/dnd5e-dice-roller)
![Build](https://github.com/MitchB09/dice-roller/actions/workflows/node.js.yml/badge.svg)
![NPM License](https://img.shields.io/npm/l/dnd5e-dice-roller)
![size](https://img.shields.io/bundlephobia/min/dnd5e-dice-roller)

Generate dice rolls based on standard ttrpg dice string.

For example:s

- 1d4 - 1 roll of a 4 sided dice. Returns a result between 1 and 4
- d6 - 1 roll of a 6 sided dice. Returns a result between 1 and 6
- 3d8 - 3 rolls of an 8 sided dice. Returns a result between 3 and 24
- 1d6+2 - 1 roll of a 6 sided dice, plus 2. Returns a result between 3 and 8
- 1d4-1 - 1 roll of a 4 sided dice, minus 1. Returns a result between 0 and 3
- 4d6dl1 - 4 rolls of a 6 sided dice, dropping the lowest. Returns a result between 3 and 18
- 2d20dh1 - 2 rolls of a 20 sided dice, dropping the lowest. (i.e. Rolling with disadvantage)
- 2d20d1+3 - 2 rolls of a 20 sided dice, dropping the lowest, plus 3. (i.e. Rolling with advantage with a modifier)

## Usage

Default export returns the total and the the rolls of each die
```javascript
import diceRoller  from 'dnd5e-dice-roller';

diceRoller("2d8+3"); // Returns { total: 17, rolls: [8, 6], rollStr: "2d8+3"  }
```

Named exports of `diceRoller` (behaves the same as the default) and `roll` to just return the total
```javascript
import { diceRoller, roll }  from 'dnd5e-dice-roller';

diceRoller("2d8+3"); // Returns { total: 17, rolls: [8, 6], rollStr: "2d8+3"  }
roll("2d8+3"); // Returns 17
```

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