Blog Image

Convert Excel to JSON in ReactJS in just 2 steps

Nadeem Shareef | Tue Nov 23 2021

Hello Developers 🙌

Today we will see how to convert Excel to JSON

We will use xlsx package.

No more talking let's jump into the coding part.

Install xlsx package

npm i xlsx

Create a basic structure for file upload

  <label htmlFor="upload">Upload File</label>
  <input type="file" name="upload" id="upload" onChange="{readUploadFile}" />

Convert Excel file to JSON

const readUploadFile = (e) => {
  if ( {
    const reader = new FileReader();
    reader.onload = (e) => {
      const data =;
      const workbook =, { type: "array" });
      const sheetName = workbook.SheetNames[0];
      const worksheet = workbook.Sheets[sheetName];
      const json = xlsx.utils.sheet_to_json(worksheet);

Kaboom!🔥 in just two simple steps, you can convert Excel to JSON


Closing here 👋👋👋

This is Shareef. My recent project yourounotes My Portfolio Twitter ShareefBhai99 > Linkedin My other Blogs