How to Convert Excel File into JSON in Javascript

Websolutionstuff | Jul-07-2021 | Categories : jQuery

Today in this small post i will show you how to convert excel file into json in javascript. Many time we have requirment to convert excel data into json and need to import into database so here, we will convert excel file into json object using javascript.

Here, we are creating html file to export excel to json data example.

<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>How to Convert Excel File into JSON in Javascript</title>

    <input type="file" id="fileUpload" accept=".xls,.xlsx" /><br />
    <button type="button" id="uploadExcel">Convert</button>
    <pre id="jsonData"></pre>
    var selectedFile;
      .addEventListener("change", function(event) {
        selectedFile =[0];
      .addEventListener("click", function() {
        if (selectedFile) {
          var fileReader = new FileReader();
          fileReader.onload = function(event) {
            var data =;

            var workbook =, {
              type: "binary"
            workbook.SheetNames.forEach(sheet => {
              let rowObject = XLSX.utils.sheet_to_row_object_array(
              let jsonObject = JSON.stringify(rowObject);
              document.getElementById("jsonData").innerHTML = jsonObject;


Recommended Post
Featured Post
11+ Laravel Tips: Optimize Database Queries (2024)
11+ Laravel Tips: Optimize Dat...

Hey developers! If you're like me, constantly striving to make your Laravel applications faster and more effici...

Read More


10 Powerful React Native Tools for 2024
10 Powerful React Native Tools...

React Native is popular among businesses because of its speed, efficiency, and lower costs. Developers also appreciate i...

Read More


How To Create Dynamic Pie Chart In Laravel
How To Create Dynamic Pie Char...

In this article, we will see how to create a dynamic pie chart in laravel. charts are used to represent data i...

Read More


Laravel 9 Group Column Chart Using Highcharts
Laravel 9 Group Column Chart U...

In the world of web development, Laravel 9 is a user-friendly PHP framework. When combined with Highcharts, a top JavaSc...

Read More