Registry / data / csv-loader

csv-loader

JSON →
library3.0.5jsnpmunverified

A webpack loader that imports CSV files as JSON with automatic type conversion using Papa Parse. Version 3.0.5 is current, released in 2022 with security updates for transitive dependencies. It supports TSV, DSV, and any delimited file by detecting delimiters. Compared to raw Papa Parse, it integrates seamlessly into webpack builds and provides type coercion (dynamicTyping) by default. Maintenance is infrequent, but compatibility extends to webpack 4 and 5. Not recommended for large streaming files; limited to synchronous loading.

npm install csv-loader
INSTALL
IMPORT
SIG · CSV-LOADER
C
csv-loader
datajavascriptv3.0.5
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–223 runs
build_error
glibc
node 18–223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default export
✓ module.exports = { ... }
✗ import data from 'data.csv'
Loader returns exports object, not default. Use import with * as or destructure.
webpack rule
✓ { test: /\.csv$/, loader: 'csv-loader', options: { dynamicTyping: true } }
✗ { test: /\.csv$/, use: 'csv-loader' }
Options object is passed to Papa Parse.
reading data
✓ import data from 'file.csv'; // data is parsed JSON
✗ const data = require('file.csv')
ESM import works in webpack; require also works but is CJS.

Configure webpack to use csv-loader with Papa Parse options, then import CSV files as typed JSON arrays.

// webpack.config.js module.exports = { module: { rules: [ { test: /\.csv$/, loader: 'csv-loader', options: { dynamicTyping: true, header: true, skipEmptyLines: true } } ] } }; // app.js import employees from './employees.csv'; console.log(employees); // Array of objects with typed values
Debug
Known issues
breakingv3.0.0 requires papaparse as a peer dependency, not bundled.
fix
Run npm install --save-dev papaparse
affects: >=3.0.0
deprecatedloader-utils is no longer necessary in webpack 5; functionality built-in.
fix
Upgrade to webpack 5 or remove manual loader-utils reference.
affects: >=3.0.0
gotchadynamicTyping may convert numeric strings incorrectly (e.g., zip codes).
fix
Set dynamicTyping: false or provide explicit schema.
affects: >=1.0.0
breakingv2.0.0 changed to Papa Parse defaults; overrides needed for custom delimiters.
fix
Add options.delimiter explicitly if not comma.
affects: >=2.0.0
deprecatedThe loader uses synchronous parsing; large files block the event loop.
fix
Use a different streaming parser for huge datasets.
affects: >=1.0.0
Errors
Common errors & fixes
Module not found: Error: Cannot resolve module 'papaparse'
Missing peer dependency in v3.
fix
Run npm install --save-dev papaparse
TypeError: Cannot read property 'delimiter' of undefined
Options object missing or malformed.
fix
Ensure options is an object, e.g., { loader: 'csv-loader', options: {} }
The 'data' argument of forEach is not an array
CSV file has only one row parsed as object.
fix
Set header: true or ensure file has multiple rows.
Error: Cannot find module 'loader-utils'
Missing loader-utils for webpack <5.
fix
Run npm install --save-dev loader-utils
Upgrade
Version history
3.0.5latest on npm
Audit
Dependencies
papaparserequiredcore CSV parsing engine
loader-utilsrequiredwebpack loader utilities
Agent activity
14 hits · last 30 days
node
12
OpenAI (training)
1
Resources
csv-loader — npm install csv-loader · libregistry