Python Excel to JSON Conversion With Examples

There are many ways to convert an excel file to JSON data. In this tutorial, we will look into two python modules to convert excel files to JSON.

  1. excel2json-3
  2. Pandas

Converting Excel File to JSON Files using excel2json-3 Module

It’s a very simple module to convert excel files to JSON files. The contents from the excel sheet are converted to JSON string and saved in a file.

The name of the files is derived from the excel sheet names. So, if there are two sheets with the name “Numbers” and “Cars”, the JSON files will be named as Numbers.json and Cars.json respectively.

The module supports both .xls and .xlsx file formats for conversion. We can read the excel file from the file system as well as the URL.

We can install this module using the PIP command.

For our example, I have created an excel file named “records.xlsx” having three sheets.

Python Excel to JSON Conversion


Here is the script to convert this excel file to JSON files.

The script creates three JSON files.




If you have to read the excel file from a URL, use convert_from_url() function.

Limitations of excel2json-3 module

  • The plugin has very limited features.
  • There are no options to skip any sheet, rows, and columns. This makes it hard to use with bigger excel files.
  • The JSON is saved into files. Most of the times, we want to convert to JSON and use it in our program rather than saving it as a file.
  • The integers are getting converted to the floating point numbers.

Converting Excel Sheet to JSON String using Pandas Module

Pandas module provides functions to read excel sheets into DataFrame object. There are many options to specify headers, read specific columns, skip rows, etc. You can read more about it at Pandas read_excel() – Reading Excel File in Python.

We can use the to_json() function to convert the DataFrame object to JSON string. Let’s look at a simple example to read the “Employees” sheet and convert it to JSON string.


So, the JSON data is created with the orientation of columns. If you want to create the JSON string with row-wise orientation, pass the “orient” parameter value as “records”.



If you have a simple and well-structured excel file and you want to convert it to JSON files, use the excel2json-3 module. But, if you want more control on the way the excel data is read and converted to JSON string, use the pandas’ module.


By admin

Leave a Reply

%d bloggers like this: