Excel is the most widely used spreadsheet application, but modern web applications, APIs, and databases work with JSON. Whether you're building a REST API, populating a MongoDB database, or creating test data for a frontend app, you'll often need to convert tabular Excel data into structured JSON. This guide covers four practical methods.
Understanding the Conversion
When you convert Excel data to JSON, each row becomes a JSON object, and each column header becomes a key. For example, a simple Excel table:
| Name | Age | City |
|---|---|---|
| Alice | 30 | New York |
| Bob | 25 | London |
| Carol | 35 | Tokyo |
Becomes this JSON:
[
{ "Name": "Alice", "Age": "30", "City": "New York" },
{ "Name": "Bob", "Age": "25", "City": "London" },
{ "Name": "Carol", "Age": "35", "City": "Tokyo" }
]
Method 1: Copy-Paste with an Online Tool (Fastest)
The quickest way to convert Excel data to JSON is by copying your data and pasting it into an online converter like tab2json.com. Here's how:
- Select your data in Excel — highlight the cells including the header row. Press
Ctrl+C(orCmd+Con Mac). - Open tab2json.com in your browser.
- Paste into the input box — press
Ctrl+V. Excel copies data as tab-separated text, which the tool detects automatically. - Click "Convert" — your JSON appears instantly in the output panel.
- Copy or download — use the "Copy" button or "Download" to save as a
.jsonfile.
This method is ideal when you have a small to medium dataset and want instant results without writing code. Since tab2json.com processes everything in your browser, your data is never uploaded to any server — a key advantage for sensitive or proprietary data.
Method 2: JavaScript with the SheetJS Library
For programmatic conversion in a Node.js or browser environment, the SheetJS (xlsx) library can read Excel files directly and output JSON:
const XLSX = require('xlsx');
// Read the Excel file
const workbook = XLSX.readFile('data.xlsx');
const sheetName = workbook.SheetNames[0];
const worksheet = workbook.Sheets[sheetName];
// Convert to JSON
const jsonData = XLSX.utils.sheet_to_json(worksheet);
console.log(JSON.stringify(jsonData, null, 2));
Install SheetJS with npm install xlsx. This approach works well for automation pipelines, build scripts, or any workflow where you need to convert Excel files programmatically. SheetJS handles multiple sheets, date formats, merged cells, and formulas.
Method 3: Python with pandas
Python's pandas library is the go-to choice for data scientists and analysts. It reads Excel files natively and exports JSON in several orientations:
import pandas as pd
import json
# Read Excel file
df = pd.read_excel('data.xlsx')
# Convert to JSON (records orientation = array of objects)
json_data = df.to_json(orient='records', indent=2)
print(json_data)
# Or save to file
df.to_json('output.json', orient='records', indent=2)
Install dependencies with pip install pandas openpyxl. The orient parameter controls the JSON structure: 'records' gives an array of objects (most common), 'columns' groups by column, and 'index' uses row indices as keys.
Method 4: Command Line with csvkit
If you prefer the command line, csvkit provides the in2csv and csvjson tools that can convert Excel to JSON in one pipeline:
# Install csvkit pip install csvkit # Convert Excel to JSON in2csv data.xlsx | csvjson --indent 2 > output.json
This is great for shell scripts, CI/CD pipelines, or quick one-off conversions. The in2csv command converts Excel to CSV, and csvjson converts CSV to JSON.
Common Pitfalls and Tips
- Data types: Excel stores everything in cells with types (numbers, dates, strings). When converting to JSON, decide whether numeric values should remain strings or be parsed as numbers. Most online tools keep them as strings — if you need typed values, use a programmatic approach.
- Special characters in headers: Column names with spaces, hyphens, or special characters can cause issues in code. Consider normalizing them to snake_case or camelCase.
- Empty cells: Different tools handle empty cells differently — some output
null, others output empty strings"", and some omit the key entirely. Check the output format matches what your application expects. - Large files: For files with 100,000+ rows, browser-based tools may be slow. Use Python or Node.js for large datasets.
- Multiple sheets: If your Excel workbook has multiple sheets, most tools only convert the first sheet by default. With SheetJS or pandas, you can iterate over all sheets.
- Date formatting: Excel dates are stored as serial numbers internally. Make sure your conversion tool or library correctly formats them as ISO 8601 strings (e.g.,
2025-01-15).
Which Method Should You Use?
| Method | Best For | Complexity |
|---|---|---|
| Online tool (tab2json.com) | Quick one-off conversions, small datasets, privacy-sensitive data | None |
| JavaScript (SheetJS) | Node.js apps, build pipelines, browser-based processing | Low |
| Python (pandas) | Data analysis, large datasets, complex transformations | Low |
| Command line (csvkit) | Shell scripts, CI/CD, automation | Low |
For most users, the fastest path is to copy your data from Excel and paste it into tab2json.com. For recurring conversions or large datasets, set up one of the programmatic methods.