# Excel & CSV to JSON: Spreadsheet Rows for AI Agents and n8n (`arched_axolotl/spreadsheet-to-json`) Actor

Turn Excel (.xlsx, .xls) and CSV files into clean JSON: one item per row, keyed by the header. Finds the header row under title lines, fills merged cells, keeps numbers, dates and booleans typed, and decodes Big5, GBK, Shift-JIS and EUC-KR CSVs.

- **URL**: https://apify.com/arched_axolotl/spreadsheet-to-json.md
- **Developed by:** [Ryan Lin](https://apify.com/arched_axolotl) (community)
- **Categories:** Developer tools, Automation, AI
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-usage

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Excel & CSV to JSON: spreadsheet rows for AI agents, n8n and code

Give it links to Excel or CSV files and get every data row back as one clean JSON item, keyed by the column headers.

把 Excel（.xlsx / .xls）與 CSV 檔轉成乾淨的 JSON：一列一筆、以欄位名稱為鍵，自動找出表頭、補齊合併儲存格，並正確解碼 Big5 等編碼。

AI agents cannot open a binary `.xlsx`, and n8n workflows need rows, not files. This Actor does the boring parts that usually go wrong:

- **Finds the real header row.** Report-style sheets start with a title, a unit note and a blank line. Those are skipped and reported separately; the header is the first row that is as wide as the data and contains only text.
- **Fills merged cells.** A region name merged over five rows is present in all five rows, not only the first.
- **Keeps types.** Numbers are JSON numbers, booleans are booleans, dates are ISO strings (`2026-09-01`, `2026-09-03T14:30:00`). Whole numbers stored as `125000.0` come back as `125000`.
- **Does not destroy codes.** In CSV files `02134`, `0912345678` and 20-digit IDs stay text; only values that are unambiguously numbers are converted.
- **Reads legacy encodings.** CSV files in Big5, GBK/GB18030, Shift-JIS, EUC-KR, UTF-16 and Windows-1252 are detected and decoded, so Chinese, Japanese and Korean text is not garbled.
- **Detects the file type from the content**, not from the URL, and reports per-file errors without failing the other files.

No browser, no external API. A typical file finishes in one or two seconds.

### What you can do with it

- **Let an AI agent read a spreadsheet.** "Open this Excel file and tell me the three customers with the highest revenue" becomes one tool call.
- **Feed rows into n8n, Make or Zapier.** Each row arrives as one item, ready for an IF node, a database insert or an email.
- **Import supplier price lists, bank exports and government open data** that arrive as `.xls` or Big5 CSV.
- **Normalise many files into one dataset** and export it from Apify as JSON, CSV or Excel with consistent keys (`keyStyle: snake_case`).

### Input

Only `fileUrls` (or `files`) is needed.

| Field | Type | Default | What it does |
|---|---|---|---|
| `fileUrls` | array of strings | — | Links to `.xlsx`, `.xlsm`, `.xls`, `.csv` or `.tsv` files. Public Google Sheets links and GitHub "blob" links work too. Also accepts `data:` URLs. |
| `files` | array of objects | — | File content instead of a URL: `{"fileName": "a.xlsx", "base64": "..."}`. |
| `uploadedFiles` | array | — | Files uploaded in Apify Console. |
| `outputMode` | string | `rows` | `rows`: one item per row. `sheets`: one item per sheet with a `rows` array. |
| `sheets` | array of strings | all visible | Sheet names or numbers (starting at 1). |
| `maxRowsPerSheet` | integer | 100000 | Return at most this many data rows per sheet. |
| `headerRow` | integer | 0 (auto) | Row number of the header. 0 detects it. |
| `hasHeader` | boolean | true | Turn off for files without column names; keys become `column_1`, `column_2`, … |
| `fillMergedCells` | boolean | true | Copy the value of a merged cell to every cell it covers. |
| `includeHiddenSheets` | boolean | false | Also read hidden sheets. |
| `keyStyle` | string | `original` | `original`, `snake_case` or `camelCase`. Non-ASCII letters are kept. |
| `inferTypes` | boolean | true | CSV only: convert unambiguous numbers and `true`/`false`. |
| `includeSource` | boolean | true | Add `_file`, `_sheet` and `_row` to each row. |
| `delimiter` | string | `auto` | CSV separator: `auto`, `comma`, `semicolon`, `tab`, `pipe` or a single character. |
| `encoding` | string | `auto` | CSV text encoding, for example `big5` or `cp1252`. |
| `maxFileSizeMb` | integer | 50 | Larger files are not downloaded. |
| `proxyConfiguration` | object | off | Only if the file host refuses direct downloads. |

#### Example: preview a file for an AI agent

```json
{
    "fileUrls": ["https://go.microsoft.com/fwlink/?LinkID=521962"],
    "maxRowsPerSheet": 20,
    "keyStyle": "snake_case"
}
```

#### Example: one sheet of a report, as a single item

```json
{
    "fileUrls": ["https://example.com/q3-report.xlsx"],
    "sheets": ["Orders"],
    "outputMode": "sheets"
}
```

#### Example: file content from n8n or an agent

```json
{
    "files": [{ "fileName": "export.csv", "base64": "5aeT5ZCNLOmDqOmWgA0K..." }]
}
```

### Output

#### Rows mode (default)

One dataset item per spreadsheet row. This is a real result for Microsoft's public "Financial Sample" workbook with `keyStyle: snake_case`:

```json
{
    "segment": "Government",
    "country": "Canada",
    "product": "Carretera",
    "discount_band": "None",
    "units_sold": 1618.5,
    "manufacturing_price": 3,
    "sale_price": 20,
    "gross_sales": 32370,
    "discounts": 0,
    "sales": 32370,
    "cogs": 16185,
    "profit": 16185,
    "date": "2014-01-01",
    "month_number": 1,
    "month_name": "January",
    "year": "2014",
    "_file": "Financial Sample.xlsx",
    "_sheet": "Sheet1",
    "_row": 2
}
```

`_row` is the row number in the original sheet, so a value can be traced back. `year` is `"2014"` because that column is stored as text in the workbook; Excel cell types are kept as they are.

#### Sheets mode

One item per sheet:

```json
{
    "url": "https://example.com/q3-report.xlsx",
    "fileName": "q3-report.xlsx",
    "fileType": "xlsx",
    "sheetName": "訂單",
    "sheetIndex": 1,
    "headerRow": 4,
    "headers": ["地區", "訂單編號", "客戶 名稱", "金額", "出貨日", "已出貨"],
    "rowCount": 3,
    "truncated": false,
    "preamble": ["2026 年第三季訂單明細", "單位：新臺幣元 製表日：2026-10-01"],
    "rows": [
        { "地區": "北區", "訂單編號": "A001", "客戶 名稱": "台積電", "金額": 125000, "出貨日": "2026-09-01", "已出貨": true },
        { "地區": "北區", "訂單編號": "A002", "客戶 名稱": "聯發科", "金額": 98000.5, "出貨日": "2026-09-03T14:30:00", "已出貨": false },
        { "地區": "南區", "訂單編號": "A003", "客戶 名稱": "鴻海", "金額": 43000, "出貨日": "2026-09-07", "已出貨": true }
    ],
    "warnings": [],
    "error": null
}
```

This example comes from the Actor's test workbook: the header is on row 4 under two title lines (returned in `preamble`), and "北區" is a cell merged over two rows.

#### Errors

A file that cannot be downloaded or read does not stop the run. In rows mode it produces one item:

```json
{ "_file": "https://example.com/nope.xlsx", "_sheet": null, "_row": null, "_error": "Download failed: HTTP 404 (file not found)." }
```

In sheets mode the item has the usual fields with `error` set. The run is marked as failed only when every file failed.

#### Run summary

The `OUTPUT` record of the run's key-value store lists every file with its sheets, detected header row, headers, row counts, CSV encoding and delimiter, warnings and errors. Read it when you need to know what was found before looking at the rows.

### Use with AI agents (MCP)

The Actor works as a tool for Claude, ChatGPT, Cursor and other MCP clients through the [Apify MCP server](https://mcp.apify.com). Add it with this server URL:

```
https://mcp.apify.com?tools=arched_axolotl/spreadsheet-to-json
```

Then ask in plain language, for example: *"Read https://example.com/sales.xlsx and tell me which product had the highest profit."*

Settings that work well for agents:

```json
{
    "fileUrls": ["https://example.com/sales.xlsx"],
    "outputMode": "sheets",
    "maxRowsPerSheet": 200,
    "keyStyle": "snake_case"
}
```

`outputMode: "sheets"` returns each table in one result instead of hundreds of small items, and `maxRowsPerSheet` protects the context window. For a first look at an unknown file, use `maxRowsPerSheet: 5`.

### Use with n8n

In **n8n**, add the **Apify** node, choose **Run an Actor and get dataset**, pick this Actor and paste the input JSON. In rows mode each spreadsheet row arrives as one n8n item.

A typical workflow:

1. **Trigger** — a new email attachment, a new file in Google Drive, or a schedule.
2. **Apify** — run this Actor with `fileUrls` set to the file link (or `files` with the base64 content of an n8n binary property).
3. **IF / Filter** — for example `金額` greater than 100000, and `_error` is empty.
4. **Postgres / Google Sheets / Slack** — insert or send the row.

The same works in Make and Zapier with their Apify modules, or from any tool that can call a URL:

```bash
curl -X POST "https://api.apify.com/v2/acts/arched_axolotl~spreadsheet-to-json/run-sync-get-dataset-items?token=YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"fileUrls": ["https://go.microsoft.com/fwlink/?LinkID=521962"], "maxRowsPerSheet": 10}'
```

This call waits for the run and returns the rows as JSON in one response.

### Limits to know about

- **One table per sheet.** The Actor reads one header row and the rows below it. Sheets that hold several separate tables side by side or stacked come back as one table with the first header.
- **Single-row headers.** Two-level headers (a group name above the column names) are not combined; the detected header is one row. Set `headerRow` to choose which.
- **Formulas.** The saved result of a formula is returned. A workbook written by a program that never calculated its formulas has no saved results, and those cells are `null`.
- **Formatting is ignored.** A cell showing `12.5%` holds `0.125` and that number is returned. Colours, comments, hyperlinks, charts and images are not read.
- **Merged cells in large files.** `fillMergedCells` applies to `.xlsx` files up to 20 MB; larger workbooks are streamed and only the first cell of a merge has the value (a warning says so).
- **CSV dates stay text.** `2024-03-01` and `03/01/2024` are not converted, because the day/month order cannot be known.
- **Not supported:** `.xlsb`, `.ods`, Apple Numbers, password-protected workbooks, and Google Sheets that are not shared publicly.
- **Item size.** In sheets mode a sheet larger than about 9 MB of JSON is cut to fit one dataset item; use rows mode for big sheets.

### FAQ

**How fast is it?** The 700-row, 16-column sample workbook above is downloaded and converted in about one second once the container has started.

**The wrong row was used as the header. What now?** Set `headerRow` to the correct row number (starting at 1), or `hasHeader: false` if the file has none. The `OUTPUT` record shows which row was detected.

**Why is a number returned as text?** In Excel files the cell is stored as text in the workbook (a green triangle in Excel). In CSV files the value has a leading zero, more than 15 digits, a `+` sign or a unit such as `%`; converting those would change the data.

**Can it read a Google Sheet?** Yes, if the sheet is shared with "anyone with the link": paste the normal sheet URL and the Actor downloads it as `.xlsx`. A sheet that is not public returns Google's sign-in page, which is reported as an error for that file.

**What happens if one file is broken?** The other files are still converted. The broken file gets an item with `_error` (or `error` in sheets mode) and is listed in `OUTPUT`.

**Is my data stored?** Files are processed in memory during the run. Results are stored in your own Apify dataset under your account's retention settings. No third-party service is called.

**Need PDF, Word or PowerPoint instead?** Use the companion Actor `arched_axolotl/document-to-markdown`, which also turns spreadsheets into Markdown tables.

# Actor input Schema

## `fileUrls` (type: `array`):

Links to the files to convert, one per line. Supported: Excel .xlsx / .xlsm, legacy Excel .xls, CSV and TSV. The type is detected from the file content, so the URL does not need a file extension. Links must be publicly downloadable; a Google Sheets link works when the sheet is shared with 'anyone with the link'. An entry may also be a data: URL such as 'data:application/octet-stream;base64,<content>'.

## `uploadedFiles` (type: `array`):

Upload spreadsheets from your computer instead of (or in addition to) giving URLs. Used in Apify Console; API and agent callers should use 'fileUrls' or 'files'.

## `files` (type: `array`):

For callers that hold the file content instead of a URL (n8n binary data, AI agents). A list of objects such as {"fileName": "orders.xlsx", "base64": "<base64 content>"}. The file name is optional but helps as a title. Keep base64 files to a few MB; for larger files pass a download URL in 'fileUrls'.

## `outputMode` (type: `string`):

rows (default): one dataset item per spreadsheet row, with the column headers as keys. Best for n8n (each row becomes one n8n item) and for exporting. sheets: one item per sheet, with all its rows in a 'rows' array plus headers and row count. Best for an AI agent that wants a whole table in one result.

## `sheets` (type: `array`):

Sheet names (case-insensitive) or sheet numbers starting at 1, for example \["Orders"] or \["1", "3"]. Leave empty to read every visible sheet. Ignored for CSV files.

## `maxRowsPerSheet` (type: `integer`):

Return at most this many data rows from each sheet. Use a small number such as 20 to preview a file or to keep an AI agent's context small. The OUTPUT record tells you when a sheet was cut.

## `headerRow` (type: `integer`):

Row number (starting at 1) that holds the column names. 0 (default) detects it automatically: title and note lines above the table are skipped and the first row that is as wide as the data and contains only text is used. Set it when the detection picks the wrong row.

## `hasHeader` (type: `boolean`):

Turn off for files without column names. Keys are then column_1, column_2 and so on, and every row is data.

## `fillMergedCells` (type: `boolean`):

Excel stores the value of a merged cell only in its first cell. With this on, every row covered by the merge gets the value (for example a region name merged over several rows). Applies to .xlsx files up to 20 MB and to .xls files.

## `includeHiddenSheets` (type: `boolean`):

Also read sheets that are hidden in Excel. A hidden sheet named explicitly in 'sheets' is always read.

## `keyStyle` (type: `string`):

How column headers become JSON keys. original: as written in the file ("Unit Price"). snake_case: unit_price. camelCase: unitPrice. Chinese, Japanese, Korean and accented letters are kept in every style. Empty headers become column_N and duplicate headers get a \_2, \_3 suffix.

## `inferTypes` (type: `boolean`):

CSV cells are text. With this on, values that are unambiguously numbers (42, 3.5, 1,250.5) or true/false become JSON numbers and booleans. Values with leading zeros (postcodes, phone numbers, product codes), percentages, dates and numbers longer than 15 digits stay text. Excel files always keep the cell types stored in the workbook.

## `includeSource` (type: `boolean`):

Add the file name, sheet name and original spreadsheet row number to every row item, so rows from several files and sheets can be told apart and traced back. Turn off to get only the column values.

## `delimiter` (type: `string`):

Separator of CSV files: auto (default, detected from the content), comma, semicolon, tab, pipe, or any single character.

## `encoding` (type: `string`):

Text encoding of CSV files: auto (default) handles UTF-8, UTF-16, Big5, GBK/GB18030, Shift-JIS, EUC-KR and Windows-1252. Set a name such as big5 or cp1252 to force one.

## `maxFileSizeMb` (type: `integer`):

Files larger than this are not downloaded and are reported with an error.

## `proxyConfiguration` (type: `object`):

Usually not needed. Turn on Apify Proxy only if the server hosting your files refuses direct downloads.

## Actor input object example

```json
{
  "fileUrls": [
    "https://go.microsoft.com/fwlink/?LinkID=521962"
  ],
  "outputMode": "rows",
  "maxRowsPerSheet": 100000,
  "headerRow": 0,
  "hasHeader": true,
  "fillMergedCells": true,
  "includeHiddenSheets": false,
  "keyStyle": "original",
  "inferTypes": true,
  "includeSource": true,
  "delimiter": "auto",
  "encoding": "auto",
  "maxFileSizeMb": 50,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `results` (type: `string`):

One item per spreadsheet row keyed by header (or one item per sheet in 'sheets' mode).

## `summary` (type: `string`):

Run summary: files and sheets read, row counts and any per-file errors.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "fileUrls": [
        "https://go.microsoft.com/fwlink/?LinkID=521962"
    ],
    "proxyConfiguration": {
        "useApifyProxy": false
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("arched_axolotl/spreadsheet-to-json").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "fileUrls": ["https://go.microsoft.com/fwlink/?LinkID=521962"],
    "proxyConfiguration": { "useApifyProxy": False },
}

# Run the Actor and wait for it to finish
run = client.actor("arched_axolotl/spreadsheet-to-json").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "fileUrls": [
    "https://go.microsoft.com/fwlink/?LinkID=521962"
  ],
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}' |
apify call arched_axolotl/spreadsheet-to-json --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,arched_axolotl/spreadsheet-to-json"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/r52vjW1164zvC5RmS/builds/TIi5KNx5CwkYboSVl/openapi.json
