# csv2json

> Stream and CLI to convert CSV to JSON

Latest version **2.0.2** (published 2019-11-26) · ISC license · 0 weekly downloads

## Install

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

Provides the command `csv2json`.

## Health

**Score 33/100 (F)** — status: abandoned.

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

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.0.2 |
| Published | 2019-11-26 |
| First published | 2012-06-03 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | separate (@types/csv2json) |
| Module format | CommonJS |
| Dependencies | 8 |
| Unpacked size | 6.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 39 |
| Author | Julien Fontanet |
| Maintainers | jackhq, julien-f, twilson63 |
| Keywords | csv, json, csv2json, csvtojson, stream |

## Links

- npm: https://www.npmjs.com/package/csv2json
- Repository: https://github.com/julien-f/csv2json
- Issues: https://github.com/julien-f/csv2json/issues
- npm.io page: https://npm.io/package/csv2json

## Dependencies (8)

- [pump](https://npm.io/package/pump.md) ^3.0.0
- [pumpify](https://npm.io/package/pumpify.md) ^2.0.0
- [minimist](https://npm.io/package/minimist.md) ^1.2.0
- [through2](https://npm.io/package/through2.md) ^3.0.1
- [csv-parser](https://npm.io/package/csv-parser.md) ^2.3.0
- [exec-promise](https://npm.io/package/exec-promise.md) ^0.7.0
- [promise-toolbox](https://npm.io/package/promise-toolbox.md) ^0.14.0
- [strip-bom-stream](https://npm.io/package/strip-bom-stream.md) ^4.0.0

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 2.0.2 (latest) — 2019-11-26
- 2.0.1 — 2019-11-07
- 2.0.0 — 2019-09-04
- 1.4.2 — 2018-02-20
- 1.4.1 — 2017-11-24
- 1.4.0 — 2017-11-24
- 1.3.0 — 2017-02-27
- 1.2.0 — 2017-01-20
- 1.1.0 — 2015-10-13
- 1.0.1 — 2015-10-13
- 1.0.0 — 2014-09-11
- 0.0.4 — 2012-10-02
- 0.0.2 — 2012-06-03
- 0.0.1 — 2012-06-03

## README

# csv2json

[![Package Version](https://badgen.net/npm/v/csv2json)](https://npmjs.org/package/csv2json) [![Build Status](https://travis-ci.org/julien-f/csv2json.png?branch=master)](https://travis-ci.org/julien-f/csv2json) [![PackagePhobia](https://badgen.net/packagephobia/install/csv2json)](https://packagephobia.now.sh/result?p=csv2json) [![Latest Commit](https://badgen.net/github/last-commit/julien-f/csv2json)](https://github.com/julien-f/csv2json/commits/master)

> Stream and CLI to convert CSV to JSON.

## Install

Installation of the [npm package](https://npmjs.org/package/csv2json):

Install globally if you want to use the CLI:

```
npm install --global csv2json
```

Install locally if you want to use it as a library:

```
npm install --save csv2json
```

## Usage

### CLI

```
Usage: csv2json [OPTIONS] [<input file> [<output file>]]

  -d, --dynamic-typing
    Convert booleans and numeric to their type instead of strings.

  -s <separator>, --separator=<separator>
    Field separator to use (default to comma “,”).

  -t, --tsv
    Use tab as separator, overrides separator flag.

  <input file>
    CSV file to read data from.
    If unspecified or a dash (“-”), use the standard input.

  <output file>
    JSON file to write data to.
    If unspecified or a dash (“-”), use the standard output.
```

### Stream

```javascript
var csv2json = require('csv2json');
var fs = require('fs');

fs.createReadStream('data.csv')
  .pipe(csv2json({
    // Defaults to comma.
    separator: ';'
  }))
  .pipe(fs.createWriteStream('data.json'));
```

## Contributions

Contributions are *very* welcomed, either on the documentation or on
the code.

You may:

- report any [issue](https://github.com/julien-f/csv2json/issues)
  you've encountered;
- fork and create a pull request.

## Note

Thanks to @twilson63 for letting me use the *csv2json* name on [npm](https://www.npmjs.org/).

## License

ISC © [Julien Fontanet](http://julien.isonoe.net)

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