Welcome to part 8 of our Excel to JSON series! We’ve covered user-facing tools: Web App, Excel Add-in, and WPS Add-in, along with Pro features. Today, we’re exploring the Excel to JSON API - the perfect solution for developers who need to integrate Excel to JSON functionality into their applications and workflows.

Introduction to Excel to JSON API
The Excel to JSON API provides a powerful, programmatic way to convert Excel data to JSON format. It’s designed for developers who need to:
- Automate Excel to JSON conversions in their applications
- Integrate conversion capabilities into existing workflows
- Process Excel data from web services and APIs
- Build custom solutions around Excel to JSON functionality
API Overview
Endpoint
The Excel to JSON API is accessible via a single endpoint:
1 | POST https://mcp.wtsolutions.cn/excel-to-json-api |
Two Usage Modes
The API offers two distinct usage modes:
- Standard Mode: Free of charge, with standard conversion rules
- Pro Mode: Requires valid subscription, with custom conversion rules
Standard API Usage
Request Format
The Standard API accepts POST requests with application/json content type containing one of two parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| data | string | No | Tab-separated or comma-separated text data with at least two rows (header row + data row). Either ‘data’ or ‘url’ must be provided |
| url | string | No | URL pointing to an Excel or CSV file. Either ‘data’ or ‘url’ must be provided |
Important: Provide either data or url, not both.
Request Examples
Example 1: Converting Tab-Separated Data
Request:
1 | { |
Response:
1 | { |
Example 2: Converting from URL
Request:
1 | { |
Response:
1 | { |
Response Format
The API returns a JSON object with the following structure:
| Field | Type | Description |
|---|---|---|
| isError | boolean | Indicates if there was an error processing the request |
| msg | string | ‘success’ or error description |
| data | string | Converted data as array of sheet objects if using URL, string if using direct data |
Error Response Example
1 | { |
Data Type Handling
The Standard API automatically detects and converts different data types:
- Numbers: Converted to numeric values
- Booleans: Recognizes ‘true’/‘false’ (case-insensitive) and converts to boolean values
- Dates: Detects various date formats and converts them appropriately
- Strings: Treated as string values
- Empty values: Represented as empty strings
Pro API Usage
Request Format
The Pro API accepts POST requests with application/json content type containing:
| Parameter | Type | Required | Description |
|---|---|---|---|
| data | string | No | Tab-separated or comma-separated text data. Either ‘data’ or ‘url’ must be provided |
| url | string | No | URL pointing to an Excel or CSV file. Either ‘data’ or ‘url’ must be provided |
| options | object | Yes | Optional configuration object for customizing the conversion process |
Important:
- Provide either
dataorurl, not both optionsis mandatory for Pro mode- You must have a valid Pro Code to use Pro mode
Options Object
The options object can contain the following properties:
| Property | Type | Default | Description |
|---|---|---|---|
| proCode | string | “” | Pro Code for custom conversion rules. This is mandatory. |
| jsonMode | string | “flat” | Format mode for JSON output: “nested”, or “flat” |
| header | string | “row” | Specifies which row/column to use as headers: “row” (first row) or “column” (first column) |
| delimiter | string | “.” | Delimiter character for nested JSON keys when using jsonMode: “nested”, acceptable delimiters are “.”, “_”, “__”, “/“ |
| emptyCell | string | “emptyString” | Handling of empty cells: “emptyString”, “null”, or “exclude” |
| booleanFormat | string | “trueFalse” | Format for boolean values: “trueFalse”, “10”, or “string” |
| jsonFormat | string | “arrayOfObject” | Overall JSON output format: “arrayOfObject” or “2DArray” |
| singleObjectFormat | string | “array” | Format when result has only one object: “array” (keep as array) or “object” (return as single object) |
Important Notes:
delimiterworks only whenjsonModeis “nested”singleObjectFormatworks only whenjsonFormatis “arrayOfObject”jsonFormatas “2DArray” works only whenjsonModeis “flat”proCodeis mandatory for Pro mode
Pro Request Examples
Example 1: Nested JSON with Custom Delimiter
Request:
1 | { |
Response:
1 | { |
Example 2: 2D Array Output Format
Request:
1 | { |
Response:
1 | { |
Example 3: Single Object Output Format
Request:
1 | { |
Response:
1 | { |
Implementation Examples
Python Implementation
Standard Mode
1 | import requests |
Pro Mode
1 | import requests |
JavaScript/Node.js Implementation
Standard Mode
1 | const axios = require('axios'); |
Pro Mode
1 | const axios = require('axios'); |
cURL Implementation
Standard Mode
1 | curl -X POST https://mcp.wtsolutions.cn/excel-to-json-api \ |
Pro Mode
1 | curl -X POST https://mcp.wtsolutions.cn/excel-to-json-api \ |
Error Handling
The API provides descriptive error messages for common issues:
| Error Message | Cause |
|---|---|
| Excel Data Format Invalid | Input data is not tab-separated or comma-separated |
| At least 2 rows are required | Input data has fewer than 2 rows |
| Both data and url received | Both ‘data’ and ‘url’ parameters are provided |
| Network Error when fetching file | Error downloading file from provided URL |
| File not found | File at provided URL cannot be found |
| Blank/Null/Empty cells in first row not allowed | Header row contains empty cells |
| Server Internal Error | Unexpected server error |
Best Practices for Error Handling
Always Check
isErrorFlag1
2
3
4
5
6if result["isError"]:
# Handle error
print(f"Error: {result['msg']}")
else:
# Process successful response
json_data = result["data"]Implement Retry Logic
1
2
3
4
5
6
7
8
9
10
11
12
13import time
max_retries = 3
for attempt in range(max_retries):
try:
response = requests.post(url, json=payload)
result = response.json()
if not result["isError"]:
break
except Exception as e:
if attempt < max_retries - 1:
time.sleep(2 ** attempt) # Exponential backoff
else:
raiseLog Errors for Debugging
1
2
3
4
5
6import logging
logging.basicConfig(level=logging.INFO)
if result["isError"]:
logging.error(f"API Error: {result['msg']}")
logging.error(f"Request payload: {payload}")
Use Cases
Use Case 1: Automated Data Pipeline
1 | import requests |
Use Case 2: Web Service Integration
1 | // Express.js endpoint that converts Excel to JSON |
Use Case 3: Batch Processing
1 | import requests |
Performance Considerations
Rate Limiting
Be mindful of API rate limits:
- Implement appropriate delays between requests
- Use caching for repeated conversions
- Batch requests when possible
Large Data Handling
For large Excel datasets:
- Consider splitting data into smaller chunks
- Process asynchronously to avoid blocking
- Implement progress tracking for long-running conversions
Caching Strategy
Cache conversion results to avoid redundant API calls:
1 | import hashlib |
Next Steps
Now that you understand how to use the Excel to JSON API programmatically, you’re ready to explore MCP Service integration. In our next post, we’ll cover MCP Service, which provides another way for developers to integrate Excel to JSON functionality into their workflows, particularly for those working with AI and automation tools.
Ready to integrate the API? Start building your Excel to JSON integration today!