# csvnorm

> Command line tool to normalize CSV and *SV files.

Latest version **1.2.0** (published 2026-05-27) · ISC license · 0 weekly downloads

## Install

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

Provides the command `csvnorm`.

## Health

**Score 60/100 (C)** — status: active.

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

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2026-05-27 |
| First published | 2017-04-13 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 13 |
| Unpacked size | 128.4 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Adrian Sieber |
| Maintainers | adius |
| Keywords | csv, normalize |

## Links

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

## Dependencies (13)

- [execa](https://npm.io/package/execa.md) ^9.6.1
- [tempy](https://npm.io/package/tempy.md) ^3.2.0
- [yargs](https://npm.io/package/yargs.md) ^18.0.0
- [chardet](https://npm.io/package/chardet.md) ^2.1.1
- [fs-extra](https://npm.io/package/fs-extra.md) ^11.3.5
- [csv-parse](https://npm.io/package/csv-parse.md) ^6.2.1
- [iconv-lite](https://npm.io/package/iconv-lite.md) ^0.7.2
- [@types/node](https://npm.io/package/@types/node.md) ^25.9.1
- [@types/execa](https://npm.io/package/@types/execa.md) ^2.0.2
- [@types/yargs](https://npm.io/package/@types/yargs.md) ^17.0.35
- [csv-stringify](https://npm.io/package/csv-stringify.md) ^6.7.0
- [@types/fs-extra](https://npm.io/package/@types/fs-extra.md) ^11.0.4
- [@types/tempfile](https://npm.io/package/@types/tempfile.md) ^3.0.0

## Alternatives

- [csv-to-markdown-table](https://npm.io/package/csv-to-markdown-table.md) — 47.0K weekly downloads
- [@sapphire/ratelimits](https://npm.io/package/@sapphire/ratelimits.md) — 4.4K weekly downloads
- [js-csvparser](https://npm.io/package/js-csvparser.md) — 2.0K weekly downloads
- [@adadapted/js-sdk](https://npm.io/package/@adadapted/js-sdk.md) — 251 weekly downloads
- [@grapecity/spread-sheets-sparklines](https://npm.io/package/@grapecity/spread-sheets-sparklines.md) — 103 weekly downloads

## Recent versions

- 1.2.0 (latest) — 2026-05-27
- 1.1.0 — 2022-03-01
- 1.0.0 — 2022-03-01
- 0.10.0 — 2020-10-26
- 0.9.1 — 2020-01-18
- 0.9.0 — 2020-01-18
- 0.8.0 — 2020-01-02
- 0.7.0 — 2019-12-08
- 0.6.0 — 2019-01-20
- 0.5.0 — 2019-01-08
- 0.4.3 — 2017-10-20
- 0.4.2 — 2017-10-10
- 0.4.1 — 2017-10-10
- 0.4.0 — 2017-07-03
- 0.3.1 — 2017-06-28
- … 2 more at https://npm.io/package/csvnorm/versions

## README

# Csvnorm

Command line tool to normalize CSV and \*SV files.

Steps:

- Convert to UTF-8 encoding
- Replace separator with `,`
- Reformat
  - Date columns to ISO8601
  - Number columns to `1456.25`
  - Currency columns to `1539.16 $`


## Encoding Detection

The input encoding is detected in this order:

1. **Byte Order Mark (BOM)** —
    UTF-8, UTF-16 LE/BE, and UTF-32 LE/BE BOMs are recognized
    and stripped from the output.
2. **UTF-16 heuristic** —
    Files without a BOM are identified by the alternating zero-byte pattern
    of ASCII text encoded as UTF-16 LE or BE.
3. **Strict UTF-8 validation** —
    The byte stream is checked against the UTF-8 grammar
    (rejecting overlong sequences and surrogate halves).
4. **[chardet](https://github.com/runk/node-chardet) fallback** —
    Used to discriminate between single-byte encodings
    such as ISO-8859-x and windows-125x.
5. **windows-1252** as the last resort
    if every previous step is inconclusive.

The detected encoding is shown in the interpretation summary
when the output is a terminal,
and can be overridden via `--encoding`.


## CLI Version

### Installation

```sh
npm install --global csvnorm
```


### Usage

```txt
Usage:
  csvnorm [Options] INFILE [> OUTFILE]
  csvnorm [Options] < INFILE [> OUTFILE]

Options:
  --date-format   Specify an additional prioritized input date format   [string]
  --encoding      Overwrite detected input encoding                     [string]
  --in-place      Normalize CSV file in place         [boolean] [default: false]
  --iso-datetime  Output datetimes with format YYYY-MM-DD[T]HH:mm:ss.SSS[Z]
                                                      [boolean] [default: false]
  --skip-start    Skip lines at the start of the input     [number] [default: 0]
  --skip-end      Skip lines at the end of the input       [number] [default: 0]
  --version       Show version number                                  [boolean]
  --help          Show help                                            [boolean]

Examples:
  csvnorm input.csv > normalized.csv        Normalize a CSV file
  cat input.csv | csvnorm > normalized.csv  Pipe and normalize a CSV file
  csvnorm --date-format "dd/mm/yyyy" i.csv  Normalize a CSV file with an unusual
                                            date format
```


## Node Module

### Installation

```sh
npm install --save csvnorm
```

`csvnorm` is an ES module and requires Node.js 20 or later.


### Usage

With files:

```js
import csvnorm from "csvnorm"

csvnorm({
  filePath: csvFilePath,
  inPlace: true,
})
```


With streams:

```js
import csvnorm from "csvnorm"

csvnorm({
  readableStream: process.stdin,
  writableStream: process.stdout,
})
```

**Warning:**
Numbers from `1,000` to `999,999` with 3 decimal places
are parsed as floats (`1.000` to `999.999`).
Only numbers larger than `1,000,000`
or numbers with less or more than 3 decimal places
can be unambiguously parsed as integers (`1000000`).

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