# File to JSON Converter (CSV, Excel, XML, iCal, vCard, GPX) (`landlordtools/file-to-json`) Actor

Turn the files people actually have (CSV in any style, Excel .xlsx, XML, iCalendar, vCard, GPX, GeoJSON, fixed-width text) into clean JSON rows for AI agents, APIs and Apify datasets. From a URL, text or base64.

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

## Pricing

from $0.30 / 1,000 records

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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

## 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

## File to JSON Converter (CSV, Excel, XML, iCal, vCard, GPX)

AI agents, APIs and Apify Actors work with JSON, but people have spreadsheets, exports and attachments. Give this Actor a file (a URL, the text, or base64) and it returns clean JSON records, one per row, event, contact or point. It works out the format itself. It's the reverse of **dataset-format-converter**, and every format that writes is read back here in the tests.

### Formats

| `format` | Reads | Notes |
|---|---|---|
| `csv`, `tsv` | Any CSV style [1]: comma, semicolon (European Excel), tab or pipe; BOM; quoted line breaks; UTF-8, UTF-16 or Windows-1252 | Delimiter detected from the first line |
| `xlsx` | Excel workbooks [2] | Pick a sheet by name or number. Numbers, true/false and dates come back typed; dates are found from the cell's number format. Formulas give their saved value; error cells become null, with a warning. Old `.xls` isn't supported |
| `xml` | Any XML [3] | Records are the most repeated element under the root (or `recordElement`). Attributes become `@name`, repeated children become lists. DOCTYPEs are refused, which blocks entity-expansion attacks [8] |
| `ics` | iCalendar events and to-dos [4] | Folded lines joined, text unescaped. All-day dates as `YYYY-MM-DD`, UTC times with `Z`, local times with their `timeZone` |
| `vcard` | vCard 3 and 4 contacts [5] | fn, name, org, title, email, tel, url, address, note |
| `gpx` | Waypoints, routes and tracks [6] | lat, lon, elevation, time, name, with track and segment numbers |
| `geojson` | Feature collections [7] | Properties plus lat/lon for points, or the geometry as JSON |
| `json`, `jsonl` | Lists, wrapped lists (`{"data": {"results": [...]}}`), JSON Lines | The list of records is found automatically (or set `recordPath`) |
| `fixed-width` | Mainframe and legacy text files | Needs a `layout`: the one dataset-format-converter writes, or a list of widths |

Values that are clearly numbers or true/false are typed. Text with leading zeros, such as account numbers, phone numbers and `00123`, stays text. Decimal commas stay text too, because `1,234` is ambiguous. Set `typeValues: false` to keep everything as text.

### Input

```json
{
  "text": "Site;Region;Capacity MW;Live;Account\nExample site A;West Midlands;12.5;true;00123\n\"Example site B; phase 2\";East of England;40;false;00456\n",
  "fileName": "sites.csv"
}
```

Give exactly one of `url` (public http or https links only; local and private-network addresses are refused [9]), `text` or `base64`. Files can be up to 20 MB and give up to 100,000 records.

### Example output

The first record:

```json
{
  "Site": "Example site A",
  "Region": "West Midlands",
  "Capacity MW": 12.5,
  "Live": true,
  "Account": "00123"
}
```

The dataset holds one item per record. The OUTPUT record adds the format found, the columns, details (delimiter, sheet names, record element) and warnings.

### Integrations

Ready-made files in [`integrations/`](integrations/README.md): a **Microsoft Power Platform custom connector** (Power Automate, Power Apps, Logic Apps, Copilot Studio), **OpenAPI 3** (Azure API Management, Postman, n8n, AI agents), an **Excel / Power BI Power Query** script, a **Google Sheets** function, and curl, Python and JavaScript examples. Apify's own Zapier, Make and n8n apps and its MCP server work too, so an AI agent can hand it an attachment link and get records back.

### Pricing

Pay per event: $0.30 per 1,000 results ($0.0003 each), plus Apify's minimal start fee. A result is one row in the dataset: one record read from your file. The run stops at your spending limit.

### Sources

1. [RFC 4180: Common Format and MIME Type for CSV Files](https://www.rfc-editor.org/rfc/rfc4180). Accessed 3 October 2026.
2. [Ecma International: ECMA-376 Office Open XML File Formats](https://ecma-international.org/publications-and-standards/standards/ecma-376/). Accessed 3 October 2026.
3. [W3C: Extensible Markup Language (XML) 1.0](https://www.w3.org/TR/xml/). Accessed 3 October 2026.
4. [RFC 5545: iCalendar](https://www.rfc-editor.org/rfc/rfc5545). Accessed 3 October 2026.
5. [RFC 6350: vCard Format Specification](https://www.rfc-editor.org/rfc/rfc6350). Accessed 3 October 2026.
6. [GPX 1.1 Schema Documentation](https://www.topografix.com/GPX/1/1/). Accessed 3 October 2026.
7. [RFC 7946: The GeoJSON Format](https://www.rfc-editor.org/rfc/rfc7946). Accessed 3 October 2026.
8. [OWASP: XML External Entity Prevention Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/XML_External_Entity_Prevention_Cheat_Sheet.html). Accessed 3 October 2026.
9. [OWASP: Server-Side Request Forgery Prevention Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Server_Side_Request_Forgery_Prevention_Cheat_Sheet.html). Accessed 3 October 2026.

[1]: https://www.rfc-editor.org/rfc/rfc4180

[2]: https://ecma-international.org/publications-and-standards/standards/ecma-376/

[3]: https://www.w3.org/TR/xml/

[4]: https://www.rfc-editor.org/rfc/rfc5545

[5]: https://www.rfc-editor.org/rfc/rfc6350

[6]: https://www.topografix.com/GPX/1/1/

[7]: https://www.rfc-editor.org/rfc/rfc7946

[8]: https://cheatsheetseries.owasp.org/cheatsheets/XML_External_Entity_Prevention_Cheat_Sheet.html

[9]: https://cheatsheetseries.owasp.org/cheatsheets/Server_Side_Request_Forgery_Prevention_Cheat_Sheet.html

# Actor input Schema

## `url` (type: `string`):

A public http(s) link to the file.

## `text` (type: `string`):

The file's contents, for text formats (CSV, XML, iCalendar, vCard, GPX, JSON, fixed width).

## `base64` (type: `string`):

Any file, base64-encoded (use this for .xlsx when you don't have a URL).

## `fileName` (type: `string`):

Optional; its extension helps detection (for example .tsv or .jsonl).

## `format` (type: `string`):

auto (default) or one of the listed formats.

## `header` (type: `boolean`):

CSV and Excel: default true.

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

Detected from the first line unless set: , ; | or a tab.

## `sheet` (type: `string`):

A sheet name, or its number counting from 1 (default: the first sheet).

## `recordElement` (type: `string`):

The element that holds one record (default: the most repeated element under the root).

## `recordPath` (type: `string`):

Dotted path to the list of records (default: the longest list in the top two levels).

## `layout` (type: `object`):

{fields: \[{name, start, width}]} as written by dataset-format-converter, or a list of widths.

## `typeValues` (type: `boolean`):

Turn text that is clearly a number or true/false into one (default true). Text with leading zeros stays text.

## `maxRows` (type: `integer`):

1 to 100000 (default 100000).

## Actor input object example

```json
{
  "text": "Site;Region;Capacity MW;Live;Account\nExample site A;West Midlands;12.5;true;00123\n\"Example site B; phase 2\";East of England;40;false;00456\n",
  "fileName": "sites.csv"
}
```

# Actor output Schema

## `result` (type: `string`):

No description

## `output` (type: `string`):

No description

# 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 = {
    "text": `Site;Region;Capacity MW;Live;Account
Example site A;West Midlands;12.5;true;00123
"Example site B; phase 2";East of England;40;false;00456`,
    "fileName": "sites.csv"
};

// Run the Actor and wait for it to finish
const run = await client.actor("landlordtools/file-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 = {
    "text": """Site;Region;Capacity MW;Live;Account
Example site A;West Midlands;12.5;true;00123
\"Example site B; phase 2\";East of England;40;false;00456
""",
    "fileName": "sites.csv",
}

# Run the Actor and wait for it to finish
run = client.actor("landlordtools/file-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 '{
  "text": "Site;Region;Capacity MW;Live;Account\\nExample site A;West Midlands;12.5;true;00123\\n\\"Example site B; phase 2\\";East of England;40;false;00456\\n",
  "fileName": "sites.csv"
}' |
apify call landlordtools/file-to-json --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,landlordtools/file-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/c1ad9YpYfO6VVJ4q6/builds/4THSNJkuDcAk6R3rp/openapi.json
