Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
R

react-papaparse

> 前端框架
Open source

react-papaparse is the fastest in-browser CSV (or delimited text) parser for React. It is full of useful features such as CSVReader, CSVDownloader, readString,

381 stars0 likes2 views
WebsiteGitHub

About

react-papaparse is the fastest in-browser CSV (or delimited text) parser for React. It is full of useful features such as CSVReader, CSVDownloader, readString,

react-papaparse

react-papaparse is the fastest in-browser CSV (or delimited text) parser for React. It is full of useful features such as CSVReader, CSVDownloader, readString, jsonToCSV, readRemoteFile, ... etc.

Features

  • Compatible with both JavaScript and TypeScript
  • Easy to use
  • Parse CSV files directly (local or over the network)
  • Fast mode (is really fast)
  • Stream large files (even via HTTP)
  • Reverse parsing (converts JSON to CSV)
  • Auto-detect delimiter
  • Worker threads to keep your web page reactive
  • Header row support
  • Pause, resume, abort
  • Can convert numbers and booleans to their types
  • One of the only parsers that correctly handles line-breaks and quotations

Install

react-papaparse is available on npm. It can be installed with the following command:

bash
npm install react-papaparse --save

react-papaparse is available on yarn as well. It can be installed with the following command:

bash
yarn add react-papaparse --save

Demo & Documentation

  • Demo

To learn how to use react-papaparse:

  • Documentation

Useful Features

  • CSVReader – React component that handles csv files input and returns its content as array.
  • CSVDownloader – React component that render the link/button which is clicked to download the data provided in CSV format.
  • readString – The function that read CSV comma separated string and returns its content as array.
  • readRemoteFile – The function that read remote CSV files and returns its content as array.
  • jsonToCSV – The function that read an array of object (json) and returns its content as CSV comma separated string.

Usage

CSVReader

Basic Upload

…

Click and Drag Upload

…

Drag ( No Click ) Upload

…

Click ( No Drag ) Upload

…

CSVDownloader

Just pass in the js object with an optional configuration ( setting delimiter / separator ).

Note: If you want to open your CSV files in Excel, you might want to set bom={true} or bom, default is false. This option adds the so called BOM byte '\ufeff' to the beginning of your CSV files and tells Excel that the encoding is UTF8.

Button

javascript
import React from 'react';

import { useCSVDownloader } from 'react-papaparse';

export default function CSVDownloader() {
  const { CSVDownloader, Type } = useCSVDownloader();

  return (
    
      Download
    
  );
}

Link

javascript
import React from 'react';

import { useCSVDownloader } from 'react-papaparse';

export default function CSVDownloader() {
  const { CSVDownloader, Type } = useCSVDownloader();

  return (
    
      Download
    
  );
}

Data as a Function/Callback

data={} can be a synchronous or asynchronous function that returns a data object.

javascript
import React from 'react';

import { useCSVDownloader } from 'react-papaparse';

export default function CSVDownloader() {
  const { CSVDownloader } = useCSVDownloader();

  return (
     {
        return [
          {
            "Column 1": "1-1",
            "Column 2": "1-2",
            "Column 3": "1-3",
            "Column 4": "1-4",
          }
        ]}
      }
    >
      Download
    
  );
}

readString

…

readRemoteFile

javascript
import React from 'react';

import { usePapaParse } from 'react-papaparse';

export default function ReadRemoteFile() {
  const { readRemoteFile } = usePapaParse();

  const handleReadRemoteFile = () => {
    readRemoteFile(url, {
      complete: (results) => {
        console.log('---------------------------');
        console.log('Results:', results);
        console.log('---------------------------');
      },
    });
  };

  return  handleReadRemoteFile()}>readRemoteFile;
}

jsonToCSV

…

Header Row Support

If you tell react-papaparse there is a header row, each row will be organized by field name instead of index.

javascript
import { usePapaParse } from 'react-papaparse';

const { readString } = usePapaParse();

readString(csvString, {
  header: true,
  worker: true,
  complete: (results) => {
    console.log('---------------------------');
    console.log(results);
    console.log('---------------------------');
  },
});

Stream

That's what streaming is for. Specify a step callback to receive the results row-by-row. This way, you won't load the whole file into memory and crash the browser.

javascript
import { usePapaParse } from 'react-papaparse';

const { readRemoteFile } = usePapaParse();

readRemoteFile(url, {
  step: (row) => {
    console.log('Row:', row.data);
  },
  complete: () => {
    console.log('All done!');
  }
});

Changelog

Latest version 4.4.0 (2023-10-14):

  • Handle parsing utf-8 bom encoded files
  • Rename duplicate headers
  • Improve iso-date regex

Version 4.3.0 (2023-10-10):

  • Enable async callback function for CSVDownloader

Version 4.2.2 (2023-10-09):

  • Fix type

Version 4.2.0 (2023-10-07):

  • Upgrade dependencies

Version 4.1.0 (2022-08-07):

  • Import readString, readRemoteFile and jsonToCSV as pure function

Version 4.0.4 (2022-08-06):

  • Add optional required prop for input file

Version 4.0.2 (2022-01-26):

  • Fix onUploadAccepted signature when a preview is set

Version 4.0.1 (2022-01-21):

  • Fix config props does not work in CSVReader

Version 4.0.0 (2022-01-18):

  • Improve code performance
  • Rewrite any existing based components to hooks

Details changes for each release are documented in the CHANGELOG.md.

️ Roadmap

v4.4.x

  • CSVReader multiple files drag and drop

❗ Issues

If you think any of the react-papaparse can be improved, please do open a PR with any updates and submit any issues. Also, I will continue to improve this, so you might want to watch/star this repository to revisit.

Contribution

We'd love to have your helping hand on contributions to react-papaparse by forking and sending a pull request!

Your contributions are heartily ♡ welcome, recognized and appreciated. (✿◠‿◠)

How to contribute:

  • Open pull request with improvements
  • Discuss ideas in issues
  • Spread the word
  • Reach out with any feedback

Contributors

      Bunlong
    
  


  
    
    

    
      Tim Tutt
    
  


  
    
    

    
      Pieter Kuppens
    
  


  
    
    

    
      Jack Zhao
    
  


  
    
    

    
      Pablo Menichini
    
  


  
    
    

    
      Mystical Tech
    
  






  
    
    

    
      Bruno
    
  


  
    
    

    
      Samuel Hulla
    
  


  
    
    

    
      glinkot
    
  


  
    
    

    
      Paul Leavitt
    
  


  
    
    

    
      Gabriel
    
  


  
    
    

    
      Izaak
    
  






  
    
    

    
      Oliver
    
  


  
    
    

    
      Ole Skaar
    
  


  
    
    

    
      Des
    
  


  
    
    

    
      Karl
    
  


  
    
    

    
      Max
    
  


  
    
    

    
      Kostas
    
  






  
    
    

    
      Dalitzky
    
  


  
    
    

    
      John Quinlivan
    
  


  
    
    

    
      Gareth Jones
    
  


  
    
    

    
      Chrys Exaucet
    
  


  
    
    

    
      Stefee
    
  


  
    
    

    
      Christopher Thomas
    
  






  
    
    

    
      Venelin Banov
    
  


  
    
    

    
      Joey Baker
    
  


  
    
    

    
      Michiel De Mey
    
  


  
    
    

    
      Mohammed Hussam
    
  


  
    
    

    
      Xiaochao Liu
    
  


  
    
    

    
      Jake Haitsma

‍‍ Advertisement

You maybe interested.

  • React Patterns – React patterns & techniques to use in development for React Developer.
  • Next Share – Social media share buttons for your next React apps.
  • Next QRCode – React hooks for generating QR code for your next React apps.
  • Next Time Ago – A lightweight tiny time-ago component for your next React apps.

⚖️ License

The MIT License

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

TypeScriptbrowser-csvcsvcsv-parsercsv-reader

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category前端框架
PricingOpen source

> Related tools

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架