# @rollup/plugin-dsv

> Convert .csv and .tsv files into JavaScript modules with d3-dsv

Latest version **4.0.0** (published 2026-05-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install @rollup/plugin-dsv
pnpm add @rollup/plugin-dsv
yarn add @rollup/plugin-dsv
bun add @rollup/plugin-dsv
```

## Health

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

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

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 4.0.0 |
| Published | 2026-05-29 |
| First published | 2019-11-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 5 |
| Unpacked size | 9.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 3756 |
| Author | Rich Harris |
| Maintainers | shellscape, rich_harris, guybedford, lukastaegert |
| Keywords | rollup-plugin |

## Links

- npm: https://www.npmjs.com/package/@rollup/plugin-dsv
- Repository: https://github.com/rollup/plugins
- Homepage: https://github.com/rollup/plugins/tree/master/packages/dsv#readme
- Issues: https://github.com/rollup/plugins/issues
- npm.io page: https://npm.io/package/@rollup/plugin-dsv

## Dependencies (5)

- [d3-dsv](https://npm.io/package/d3-dsv.md) 2.0.0
- [tosource](https://npm.io/package/tosource.md) ^2.0.0-alpha.3
- [strip-bom](https://npm.io/package/strip-bom.md) ^4.0.0
- [@types/d3-dsv](https://npm.io/package/@types/d3-dsv.md) ^3.0.0
- [@rollup/pluginutils](https://npm.io/package/@rollup/pluginutils.md) ^5.0.1

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 4.0.0 (latest) — 2026-05-29
- 3.0.5 — 2024-09-23
- 3.0.4 — 2023-10-05
- 3.0.3 — 2023-09-25
- 3.0.2 — 2023-01-20
- 3.0.1 — 2022-10-21
- 3.0.0 — 2022-10-09
- 2.0.3 — 2021-12-28
- 2.0.2 — 2021-07-26
- 2.0.1 — 2020-02-01
- 2.0.0 — 2019-11-29

## README

[npm]: https://img.shields.io/npm/v/@rollup/plugin-dsv
[npm-url]: https://www.npmjs.com/package/@rollup/plugin-dsv
[size]: https://packagephobia.now.sh/badge?p=@rollup/plugin-dsv
[size-url]: https://packagephobia.now.sh/result?p=@rollup/plugin-dsv

[![npm][npm]][npm-url]
[![size][size]][size-url]
[![libera manifesto](https://img.shields.io/badge/libera-manifesto-lightgrey.svg)](https://liberamanifesto.com)

# @rollup/plugin-dsv

🍣 A Rollup plugin which converts `.csv` and `.tsv` files into JavaScript modules with [d3-dsv](https://github.com/d3/d3-dsv).

## Requirements

This plugin requires an [LTS](https://github.com/nodejs/Release) Node version (v14.0.0+) and Rollup v2.78.0+.

## Install

Using npm:

```console
npm install @rollup/plugin-dsv --save-dev
```

## Usage

Create a `rollup.config.js` [configuration file](https://www.rollupjs.org/guide/en/#configuration-files) and import the plugin:

```js
import dsv from '@rollup/plugin-dsv';

export default {
  input: 'src/index.js',
  output: {
    dir: 'output',
    format: 'cjs'
  },
  plugins: [dsv()]
};
```

Then call `rollup` either via the [CLI](https://www.rollupjs.org/guide/en/#command-line-reference) or the [API](https://www.rollupjs.org/guide/en/#javascript-api).

## Practical Example

Suppose that you have a CSV (or TSV!) file which contains some information on delicious fruits:

```csv
type,count
apples,7
pears,4
bananas,5
```

And suppose you'd like to import that CSV as an `Array` within some part of your code. After adding the plugin (as shown above), you may `import` (or `require`) the CSV file directly. The import will provide an `Array` of `Objects` representing rows from the CSV file:

```js
import fruit from './fruit.csv';

console.log(fruit);
// [
//   { type: 'apples', count: '7' },
//   { type: 'pears', count: '4' },
//   { type: 'bananas', count: '5' }
// ]
```

## Options

### `processRow`

Type: `Function`<br>
Default: `null`

Specifies a function which processes each row in the parsed array. The function can either manipulate the passed `row`, or return an entirely new row object.

This option could be used for converting numeric `string` values into `Number` values. – for example turning numeric values into numbers, e.g.

```js
dsv({
  processRow: (row, id) => {
    Object.keys(row).forEach((key) => {
      var value = row[key];
      row[key] = isNaN(+value) ? value : +value;
    });
  }
});
```

## Meta

[CONTRIBUTING](./.github/CONTRIBUTING.md)

[LICENSE (MIT)](./LICENSE)

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