Guide · Open source
How to use PapaParse: install and parse CSV in JavaScript
Updated · written with AI from the project's own documentation and checked against our catalogue data
Papa Parse is a JavaScript library that reads comma-separated (CSV) and other delimited text and turns it into data your program can use. It also converts JSON back into CSV. This guide shows you how to install it, parse files in a web page or Node.js, and use its main options so you can import CSV data reliably.
Quick start
- 1Install the package. Run npm install papaparse in your project folder. Node.js or npm must be available first.
- 2Import the library. Add import Papa from 'papaparse'; at the top of your script.
- 3Call Papa.parse. Pass your File or string and a config object to Papa.parse to read the CSV.
- 4Set options for your file. Use the config to turn on header rows, type conversion or delimiter detection, as described in the documentation.
- 5Handle large files. For big inputs, use the streaming and worker options so the page stays responsive.
- 6Convert back to CSV if needed. Call Papa.unparse with your data to produce a CSV string.
Install PapaParse with npm
Papa Parse is available on npm. If you use npm, install it from your project folder with the command below. The README lists Node.js or npm as the prerequisite for this method.
If you do not want to use npm, the README says you can download papaparse.min.js and add it to your project source directly.
- Prerequisites: Node.js or npm, if installing via npm
- Papa Parse has no dependencies
npm install papaparseImport PapaParse and call parse
Import the library, then call Papa.parse with your file and a config object. The README's basic usage shows the two main calls: Papa.parse for reading CSV and Papa.unparse for writing it.
The file argument can be a File object or a string, and the config object controls how parsing behaves.
import Papa from 'papaparse';
Papa.parse(file, config);
const csv = Papa.unparse(data[, config]);Parse local and remote CSV files
The README says Papa Parse can parse CSV files directly, whether they are local or over the network. Local files are read in chunks, and remote files can be downloaded and parsed in the same way.
For the full list of config options, such as header handling and type conversion, use the documentation linked from the project homepage. The README itself does not list every option, so check the docs before relying on a specific setting.
- Header row support: the README lists this as a feature
- Auto-detect delimiter: parsing can work out the separator
- Can convert numbers and booleans to their types
Stream large files and use worker threads
For large files, the README lists streaming (including over HTTP) and a fast mode. Streaming means the file is processed in pieces rather than read all at once.
Worker threads keep your web page responsive while parsing runs. Parsing can also be paused, resumed or aborted, which the README lists as features.
- Stream large files, even via HTTP
- Worker threads to keep your web page reactive
- Pause, resume, abort
Use PapaParse in Node.js
The README says Papa Parse can parse a Readable Stream instead of a File when used in Node.js, in addition to plain strings. In this mode, the encoding option must be a Node-supported character encoding if you set it.
In Node.js the LocalChunkSize, RemoteChunkSize, download, withCredentials and worker options are unavailable. You can also pipe a stream into Papa.parse(Papa.NODE_STREAM_INPUT, options), then listen for the data and end events.
- Pass a Readable Stream or a plain string
- Use stream.on('data', callback) to process data
- Use stream.on('end', callback) to signal the end of the stream
Convert JSON back to CSV
Papa.unparse does the reverse of parsing. It takes your data and returns a CSV string. The README lists reverse parsing as a feature, and the usage example shows the call pattern.
const csv = Papa.unparse(data[, config]);What people use it for
- Importing a CSV file a user uploads into a web page
- Loading a large CSV over HTTP in pieces instead of all at once
- Parsing CSV in a worker thread so the page stays responsive
- Reading delimited text in a Node.js script from a Readable Stream
- Exporting JSON data from a JavaScript app as a CSV file
Frequently asked questions
Is PapaParse free to use?
PapaParse is released under the MIT licence, according to the project summary. Check the LICENSE file in the repository for the full terms before you use it in a commercial project.
How do I install PapaParse?
Run npm install papaparse if you use npm. If you don't use npm, the README says you can download papaparse.min.js and add it to your project source.
Does PapaParse work in Node.js?
Yes. The README says it can parse a Readable Stream in Node.js, in addition to plain strings. Some browser-only options such as download and worker are unavailable in that mode.
Can PapaParse handle large CSV files?
The README lists streaming for large files, including over HTTP, and a fast mode. Use these options when a file is too big to read all at once.
How does PapaParse compare to csv-parse or fast-csv?
The project summary lists csv-parse, PapaCSV, fast-csv and d3-dsv as comparable projects. The README does not include a benchmark comparison, so test the libraries on your own files before choosing one.
Does PapaParse have a command-line tool?
No. It is a code library with no user interface, and the README describes only the library API. If you need a finished command-line tool or a spreadsheet editor, pick a different product.
New agent skills, repos and AI tools — every week
The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.
Our verdict
PapaParse suits JavaScript developers who need to import CSV in a browser or Node.js, especially for large files or work that must not block the page. It has no dependencies and is MIT licensed. If you only need to view or edit a spreadsheet, or your project does not use JavaScript, choose a different tool.
Install options & downloads