How to Convert XLSX to JSON in Node.js

Cloudmersive
2 min readDec 19, 2022

--

When it comes to conversions between common data types, convenience is key. With only a few lines of Node.js code (included below in this article) and a free Cloudmersive API key, you can convert your XLSX files to JSON Object Arrays in seconds.

First, run the below command to install our SDK:

npm install cloudmersive-convert-api-client --save

Or, if you prefer, add the below snippet to your package.json:

  "dependencies": {
"cloudmersive-convert-api-client": "^2.6.3"
}

After that, copy in the remaining code, providing your API key and XLSX file in their respective fields:

var CloudmersiveConvertApiClient = require('cloudmersive-convert-api-client');
var defaultClient = CloudmersiveConvertApiClient.ApiClient.instance;

// Configure API key authorization: Apikey
var Apikey = defaultClient.authentications['Apikey'];
Apikey.apiKey = 'YOUR API KEY';



var apiInstance = new CloudmersiveConvertApiClient.ConvertDataApi();

var inputFile = Buffer.from(fs.readFileSync("C:\\temp\\inputfile").buffer); // File | Input file to perform the operation on.


var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
apiInstance.convertDataXlsxToJson(inputFile, callback);

To get a free API key, visit our website and register a free account. This will provide a limit of 800 API calls per month with no additional commitments (once you reach your monthly limit, the total will reset the following month).

It’s just that easy !

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

No responses yet