{"id":21084,"library":"csv-loader","title":"csv-loader","description":"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.","status":"maintenance","version":"3.0.5","language":"javascript","source_language":"en","source_url":"https://github.com/theplatapi/csv-loader","tags":["javascript","webpack","loader","csv","types","dynamicTyping","dynamic","conversion","automatic"],"install":[{"cmd":"npm install csv-loader","lang":"bash","label":"npm"},{"cmd":"yarn add csv-loader","lang":"bash","label":"yarn"},{"cmd":"pnpm add csv-loader","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"core CSV parsing engine","package":"papaparse","optional":false},{"reason":"webpack loader utilities","package":"loader-utils","optional":false}],"imports":[{"note":"Loader returns exports object, not default. Use import with * as or destructure.","wrong":"import data from 'data.csv'","symbol":"default export","correct":"module.exports = { ... }"},{"note":"Options object is passed to Papa Parse.","wrong":"{ test: /\\.csv$/, use: 'csv-loader' }","symbol":"webpack rule","correct":"{ test: /\\.csv$/, loader: 'csv-loader', options: { dynamicTyping: true } }"},{"note":"ESM import works in webpack; require also works but is CJS.","wrong":"const data = require('file.csv')","symbol":"reading data","correct":"import data from 'file.csv'; // data is parsed JSON"}],"quickstart":{"code":"// webpack.config.js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.csv$/,\n        loader: 'csv-loader',\n        options: {\n          dynamicTyping: true,\n          header: true,\n          skipEmptyLines: true\n        }\n      }\n    ]\n  }\n};\n\n// app.js\nimport employees from './employees.csv';\nconsole.log(employees); // Array of objects with typed values","lang":"javascript","description":"Configure webpack to use csv-loader with Papa Parse options, then import CSV files as typed JSON arrays."},"warnings":[{"fix":"Run npm install --save-dev papaparse","message":"v3.0.0 requires papaparse as a peer dependency, not bundled.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Upgrade to webpack 5 or remove manual loader-utils reference.","message":"loader-utils is no longer necessary in webpack 5; functionality built-in.","severity":"deprecated","affected_versions":">=3.0.0"},{"fix":"Set dynamicTyping: false or provide explicit schema.","message":"dynamicTyping may convert numeric strings incorrectly (e.g., zip codes).","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Add options.delimiter explicitly if not comma.","message":"v2.0.0 changed to Papa Parse defaults; overrides needed for custom delimiters.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Use a different streaming parser for huge datasets.","message":"The loader uses synchronous parsing; large files block the event loop.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run npm install --save-dev papaparse","cause":"Missing peer dependency in v3.","error":"Module not found: Error: Cannot resolve module 'papaparse'"},{"fix":"Ensure options is an object, e.g., { loader: 'csv-loader', options: {} }","cause":"Options object missing or malformed.","error":"TypeError: Cannot read property 'delimiter' of undefined"},{"fix":"Set header: true or ensure file has multiple rows.","cause":"CSV file has only one row parsed as object.","error":"The 'data' argument of forEach is not an array"},{"fix":"Run npm install --save-dev loader-utils","cause":"Missing loader-utils for webpack <5.","error":"Error: Cannot find module 'loader-utils'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}