Some time in our projects we need data in json files(mostly web projects). But collecting and managing data in json files is harder(At least this is what I feel) compared to excel. I had recently ran into a similar situation where I need some data. Data is going to be provided by a non-technical person/client. And there going to be several rounds of it.

So I was looking for options what can be done here, where I found several online tools which could be used for same. But I don’t want to use that because of course privacy. I don’t want to upload an excel file to a unknown application which would process it server side give me results.

My search ended upon this. I found this nodejs module which was supper easy to use which would read your excel file and return a json object. So I created a small nodejs project which help me achieving solution to the problem.

1
2
3
4
5
6
7
8
9
var parser = require('simple-excel-to-json')
var doc = parser.parseXls2Json('sample.xlsx', { isNested: true });
const fs = require('fs');
fs.writeFileSync("sample.json",JSON.stringify(doc[0], null, 2), function(err) {
    if(err) {
        console.log("There was an error!");
        return console.log(err);
    }
});

So here is a repository link to source code. To run this you would need nodejs in your system.

You would need to a npm install and node index.js to this working.