# JSON to CSV & Excel Converter – Flatten Nested JSON & JSONL (`gazidev/json-to-csv-converter`) Actor

Convert JSON, JSONL/NDJSON or API responses to CSV or Excel in bulk, and CSV/Excel back to JSON. Nested objects are flattened to dot columns and arrays are joined or exploded to rows. Choose and order the columns and pick a delimiter, with UTF-8 BOM for Excel. Input from URLs, text or datasets.

- **URL**: https://apify.com/gazidev/json-to-csv-converter.md
- **Developed by:** [Cemal Atakli](https://apify.com/gazidev) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $6.00 / 1,000 file converteds

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

## JSON to CSV & Excel Converter – Flatten Nested JSON & JSONL

Convert **JSON, JSON Lines (JSONL / NDJSON), REST API responses and Apify datasets to CSV or Excel (XLSX)** in one
click, and convert **CSV / Excel back to JSON**. Nested objects become clean dot columns (`address.city`), arrays are
joined into one cell, exploded into rows or spread over indexed columns, and every file gets a public download link.

No code, no jq, no spreadsheet formulas: paste a URL or some JSON, press Start, download the CSV.

### What it does

- **JSON → CSV / XLSX** from any number of URLs, pasted text or an Apify dataset. One output file per input.
- **Smart flattening:** `{"address": {"geo": {"lat": 1}}}` → column `address.geo.lat`. You choose the separator.
- **Three array modes:**
  - **Join** (default): `["vip", "eu"]` → `vip; eu`.
  - **Explode to rows:** one row per element of an array of objects, parent fields repeated (one row per order line,
    per review, per variant). Limit it to one array with `explodePath`.
  - **Indexed columns:** `tags.0`, `tags.1`, `items.0.sku`...
- **Column union:** records with different fields still produce one table; missing cells stay empty.
- **Choose and order the columns**, or keep first-seen / A-Z order.
- **Finds the records automatically** in API responses (`items`, `data`, `results`, `records`, `rows`...) or use a
  JMESPath `recordsPath` such as `data.orders`.
- **CSV options:** comma, semicolon (European Excel), tab or pipe delimiter; UTF-8 BOM so Excel shows accents and
  non-Latin text correctly.
- **Real Excel types:** numbers stay numbers, ISO dates become Excel dates, bold frozen header with autofilter.
- **Reverse direction:** CSV / XLSX → JSON array; `address.city` columns become nested objects again, numbers and
  `true` / `false` become JSON values, codes such as `01234` stay text.
- **Safe and honest:** only public http(s) URLs (private network addresses are refused), size cap, retries. Invalid
  JSON, empty files and errors are reported per input and **never charged**.

#### Which gazidev converter do I need?

| You want... | Use |
|---|---|
| JSON / JSONL / API / dataset → **CSV or XLSX file**, nested JSON flattened, arrays exploded to rows | **JSON to CSV & Excel Converter** (this Actor) |
| Excel / ODS / CSV workbooks → JSON with all sheets, header detection, merged cells | [Excel to JSON Converter](https://apify.com/gazidev/spreadsheet-to-json) |
| Reshape JSON with **jq / JMESPath** expressions (filter, aggregate, rename) | [JSON Transformer](https://apify.com/gazidev/json-transformer) |
| Filter rules, **merge and dedupe datasets**, "only new items since last run" | [Dataset Filter & Transform](https://apify.com/gazidev/dataset-filter-transform) |

### Use cases

- An API or webhook returns JSON and your manager wants a spreadsheet.
- Turn a scraper's nested output (Apify dataset) into a flat CSV for Google Sheets, a CRM import or Power BI.
- Convert JSONL / NDJSON exports (logs, BigQuery, OpenAI batch files, Elasticsearch dumps) to CSV.
- Shopify / WooCommerce style orders → one row per line item with **Explode to rows**.
- A no-code step in **n8n, Make or Zapier**: "JSON in, CSV link out".
- CSV from a partner → JSON for an API or a test fixture.

### Input example

```json
{
  "jsonUrls": ["https://jsonplaceholder.typicode.com/users"],
  "outputFormat": "both",
  "arrays": "join",
  "delimiter": ",",
  "excelBom": true
}
```

Nested orders, one row per order line, only some columns:

```json
{
  "jsonText": "{\"data\":{\"orders\":[{\"id\":1,\"customer\":{\"name\":\"Ana\"},\"lines\":[{\"sku\":\"A\",\"qty\":2},{\"sku\":\"B\",\"qty\":1}]}]}}",
  "recordsPath": "data.orders",
  "arrays": "explode",
  "columns": ["id", "customer.name", "lines.sku", "lines.qty"]
}
```

CSV to JSON:

```json
{ "direction": "table-to-json", "jsonUrls": ["https://example.com/export.csv"] }
```

In an Apify integration use `"datasetId": "{{resource.defaultDatasetId}}"` to convert the output of the previous run.

### Output

The dataset has one row per input with the download links (the `OUTPUT` record has the same plus totals and charges):

```json
{
  "input": "https://jsonplaceholder.typicode.com/users",
  "status": "ok",
  "rows": 10,
  "columns": 15,
  "columnNames": ["id", "name", "username", "email", "address.street", "address.suite", "address.city", "address.zipcode", "address.geo.lat", "address.geo.lng", "phone", "website", "company.name", "company.catchPhrase", "company.bs"],
  "recordsFrom": "top-level array",
  "csvUrl": "https://api.apify.com/v2/key-value-stores/<store>/records/users.csv",
  "warnings": []
}
```

The CSV:

```
id,name,username,email,address.street,address.suite,address.city,address.zipcode,address.geo.lat,address.geo.lng,...
1,Leanne Graham,Bret,Sincere@april.biz,Kulas Light,Apt. 556,Gwenborough,92998-3874,-37.3159,81.1496,...
```

Turn on **"Also put the table rows in the dataset"** (`pushRows`) to get the converted rows in the dataset as well,
for the next step of a pipeline (charged per row, see below).

### Pricing

Pay per event, no subscription. You pay per converted input, not per row:

| Event | Price | When |
|---|---|---|
| File converted | **$0.006** | Once per input converted (CSV and XLSX both included), covers up to 10,000 rows |
| Extra 10,000 rows | $0.003 | Each further started block of 10,000 rows of the same input |
| Row pushed to dataset | $0.0002 | Only when `pushRows` is on |
| Actor start | $0.00005 | Once per run |

A 1,000-row JSON file costs **$0.006**; 25,000 rows cost $0.012. Invalid JSON, empty inputs and failed downloads are
free.

| Actor | Price for one 1,000-row file |
|---|---|
| **JSON to CSV & Excel Converter (this)** | **$0.006** |
| humble-echidna/dataset-transform | $0.001 per row = $1.00 |
| eliai/excel-to-json | $0.03 per file |

(Competitor prices from the Apify Store on 13 Nov 2026; they may change.)

Set a **maximum cost per run** and the Actor stops cleanly: the current file is cut to the rows that were paid for
(with a warning) and remaining inputs are listed as not processed in `OUTPUT`.

### Use with AI agents / Apify MCP

The input is small and predictable, so agents can call it through the [Apify MCP server](https://mcp.apify.com) or the
API: pass `jsonText` (or `jsonUrls`) and read `csvUrl` / `xlsxUrl` from the dataset. Errors come back as rows with
`status: "error"` and a readable `error` message, never as a crashed run.

### FAQ

**How big can a file be?** Up to `maxFileSizeMb` (default 100 MB). The file is converted in memory: use 1–2 GB of
run memory for files above ~100 MB. XLSX is limited to 16,384 columns and 1,048,575 rows per sheet (more rows go to
extra sheets).

**My records are inside `response.payload.items`.** Set `recordsPath` to `response.payload.items`.

**Explode created too many rows.** A record with several arrays of objects explodes into their combination (capped at
1,000 rows per record). Set `explodePath` to the one array you want, e.g. `lines`.

**Excel shows broken characters.** Keep "UTF-8 BOM" on. For a European Excel choose the semicolon delimiter.

**Can it call a private API?** Add headers in `httpHeaders` (e.g. `Authorization`). They are stored in the run input,
so use a short-lived token. URLs that resolve to private or internal network addresses are refused.

**Excel input with several sheets?** The reverse direction reads the first visible sheet. For all sheets, header
detection and merged cells use [Excel to JSON Converter](https://apify.com/gazidev/spreadsheet-to-json).

**Which datasets can it read?** Your own datasets, datasets shared with you and public ones.

# Actor input Schema

## `jsonUrls` (type: `array`):

Public URLs of JSON / JSON Lines (NDJSON) files or REST API endpoints (one output file per URL). In the 'CSV / Excel to JSON' direction: CSV or XLSX URLs. GitHub 'blob', Dropbox, Google Drive and Google Sheets share links are turned into direct downloads. Leave everything empty to convert an example API.

## `jsonText` (type: `string`):

Paste a JSON document, a JSON array or JSON Lines directly. Handy for n8n / Make steps and AI agents. In the reverse direction paste CSV text.

## `datasetId` (type: `string`):

An Apify dataset, e.g. the output of a scraper run, converted to one CSV / XLSX file. In an integration use {{resource.defaultDatasetId}}. The Actor can read your own datasets and public ones.

## `direction` (type: `string`):

JSON to CSV / Excel (default), or CSV / Excel to JSON (dot columns such as address.city become nested objects again).

## `outputFormat` (type: `string`):

CSV, Excel (XLSX with real numbers and dates, bold frozen header, autofilter) or both. Ignored in the CSV / Excel to JSON direction (the output is a JSON file).

## `recordsPath` (type: `string`):

Where the list of records is inside the JSON, e.g. 'data.items' or 'response.results'. Empty = automatic: a top-level array, or the 'items' / 'data' / 'results' / 'records' / 'rows' array of an API response, or the only array of objects.

## `arrays` (type: `string`):

Join: \['a','b'] becomes 'a; b' (arrays of objects become JSON text in one cell). Explode: one row per element of each array of objects, with the parent fields repeated (e.g. one row per order line). Indexed columns: tags.0, tags.1, items.0.sku...

## `explodePath` (type: `string`):

With 'Explode to rows': the flattened name of the one array to explode, e.g. 'lineItems' or 'order.items'. Arrays of plain values can be exploded this way too. Empty = explode every array of objects.

## `separator` (type: `string`):

Joins nested key names into column names: address.city, company.name. In the reverse direction it splits column names back into nested objects.

## `arrayJoiner` (type: `string`):

Text placed between joined array values.

## `columns` (type: `array`):

Only these columns, in this order, using the flattened names (e.g. id, name, address.city). Empty = every column found in any record (column union).

## `columnOrder` (type: `string`):

First-seen keeps the order of the fields in the records; new fields of later records are appended.

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

Comma, semicolon (European Excel), tab (TSV) or pipe.

## `excelBom` (type: `boolean`):

Starts the CSV with a byte-order mark so Excel shows accents, emoji and non-Latin text correctly. Turn off for tools that dislike the BOM.

## `convertDates` (type: `boolean`):

In the XLSX, write values like 2026-11-14 or 2026-11-14T10:30:00 as real Excel dates.

## `pushRows` (type: `boolean`):

Off (default): the dataset has one summary row per input with the download links. On: the dataset holds the converted rows themselves (for the next step of an integration) and the summary goes to the OUTPUT record. Charged per row.

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

Stop each input after this many rows (0 = no limit). Useful for a preview.

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

In the reverse direction, turn '42', '3.5', 'true' into JSON numbers and booleans. Codes with leading zeros and long digit strings stay text.

## `unflatten` (type: `boolean`):

In the reverse direction, turn 'address.city' columns into {"address": {"city": ...}} and tags.0, tags.1 into arrays.

## `inputDelimiter` (type: `string`):

Delimiter of the CSV you convert to JSON. Auto-detect works for comma, semicolon, tab and pipe.

## `httpHeaders` (type: `object`):

Optional headers sent with every URL request, e.g. {"Authorization": "Bearer ..."} for a private API. They are stored in the run input, so prefer a short-lived token.

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

Larger downloads are rejected (not charged). Raise the run memory for files above ~100 MB.

## Actor input object example

```json
{
  "jsonUrls": [
    "https://jsonplaceholder.typicode.com/users"
  ],
  "direction": "json-to-table",
  "outputFormat": "csv",
  "arrays": "join",
  "separator": ".",
  "arrayJoiner": "; ",
  "columnOrder": "first-seen",
  "delimiter": ",",
  "excelBom": true,
  "convertDates": true,
  "pushRows": false,
  "maxRows": 0,
  "inferTypes": true,
  "unflatten": true,
  "inputDelimiter": "auto",
  "maxFileSizeMb": 100
}
```

# Actor output Schema

## `files` (type: `string`):

No description

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

No description

## `results` (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 = {
    "jsonUrls": [
        "https://jsonplaceholder.typicode.com/users"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("gazidev/json-to-csv-converter").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 = { "jsonUrls": ["https://jsonplaceholder.typicode.com/users"] }

# Run the Actor and wait for it to finish
run = client.actor("gazidev/json-to-csv-converter").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 '{
  "jsonUrls": [
    "https://jsonplaceholder.typicode.com/users"
  ]
}' |
apify call gazidev/json-to-csv-converter --silent --output-dataset

```

## MCP server setup

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

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/tXKAdI8Uf2nX9iR1Q/builds/cdjnbyHzSuB7DYXxf/openapi.json
