gitmyhub

PapaParse

JavaScript ★ 13k updated 2d ago

Fast and powerful CSV (delimited text) parser that gracefully handles large files and malformed input

Papa Parse is a fast, dependency-free JavaScript library for reading and writing CSV files in browsers and Node.js, with built-in support for streaming large files.

JavaScriptsetup: easycomplexity 2/5

Papa Parse is a JavaScript library for reading and writing CSV files. CSV is a plain text format where data is laid out in rows, with each value separated by a comma or another delimiter character. It is the format you get when you export a spreadsheet. Papa Parse takes that text and turns it into structured data your JavaScript code can work with, and it can also reverse the process by converting data back into CSV text.

The README describes it as the fastest in-browser CSV parser for JavaScript and says it follows RFC 4180, which is the standard definition of how CSV should be formatted. It has no external dependencies at all, not even jQuery. Key features include reading files stored locally or fetched over a network, streaming very large files a chunk at a time so you never have to load the whole thing into memory, auto-detecting which delimiter character a file uses, recognizing a header row, and converting text representations of numbers and booleans into their proper JavaScript types. There is also an option to run parsing on a background thread so the rest of a web page stays interactive, and you can pause, resume, or stop a parse in progress.

Installing it is straightforward: it is available through npm with a single install command, or you can download one minified file and drop it directly into a project. The main API is two function calls, one to parse text into data and one to turn data back into text, each accepting a configuration object.

In Node.js environments the library works with readable streams and supports a pipe-based style in addition to plain strings, though a few browser-specific options are not available there.

The README points to a homepage with a live demo and to documentation for full usage details. Contributions are welcome through GitHub issues and pull requests, with tests expected alongside any bug fix.

Where it fits