# JSON to CSV Converter (`eloquent_mountain/json-to-csv-converter`) Actor

JSON to CSV Converter.

Effortlessly transform JSON data into CSV with our Apify actor. Handle nested structures, expand lists into rows, and customize separators and delimiters. Input via URL or paste JSON text. Ideal for data analysis and reporting!

- **URL**: https://apify.com/eloquent_mountain/json-to-csv-converter.md
- **Developed by:** [Paco](https://apify.com/eloquent_mountain) (community)
- **Categories:** Automation, Integrations, Developer tools
- **Stats:** 41 total users, 2 monthly users, 96.8% runs succeeded, 4 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

## JSON to CSV Converter

Convert any JSON data into a CSV file effortlessly with this powerful Apify actor. Handle complex nested structures and expand lists into rows with ease.

### Features

- **Handles Nested Structures**: Flattens nested JSON objects and arrays into a CSV format.
- **Expand Lists into Rows**: Option to expand lists so that each item becomes a separate row.
- **Multiple Input Methods**: Provide JSON data via URL or by pasting the JSON text directly.
- **Customizable Output**: Define custom separators for nested keys.

### Benefits

- **Ease of Use**: Convert complex JSON data without writing any code.
- **Flexibility**: Suitable for any JSON structure, no matter how deeply nested.
- **Efficiency**: Quickly transform data for analysis, reporting, or integration with other tools.

### How to Use

1. **Input Your JSON Data**:

   - **JSON File URL**: Enter the URL of your JSON file.
   - **Paste JSON Text**: Copy and paste your JSON content into the provided text area.

2. **Customize Options** (optional):

   - **Expand Lists into Rows**: Check this option to expand lists into multiple rows.
   - **Key Separator**: Set a custom separator for nested keys (default is `.`).

3. **Run the Actor**:

   - Click the **Start** button to begin the conversion process.

4. **Retrieve Your CSV File**:

   - After the run completes, download the CSV file from the **Key-value store**. Or export it to another format as per desire.

### Example

**Input JSON**:

```json
{
  "id": 1,
  "name": "John Doe",
  "emails": ["john@example.com", "jdoe@example.com"],
  "address": {
    "street": "123 Main St",
    "city": "Anytown"
  }
}
```

**Output CSV**:

| id | name     | emails\[0]          | emails\[1]          | address.street | address.city |
|----|----------|--------------------|--------------------|----------------|--------------|
| 1  | John Doe | john@example.com   | jdoe@example.com   | 123 Main St    | Anytown      |

### Support

For any questions or issues, please open an issue in the GitHub repository or contact support.

***

Unlock the full potential of your JSON data by converting it into a CSV format that's ready for analysis and reporting. Try the JSON to CSV Converter actor today!

````



# Actor input Schema

## `jsonUrl` (type: `string`):

URL of the JSON file to convert.
## `jsonText` (type: `string`):

Paste your JSON content directly.
## `separator` (type: `string`):

Separator used in the flattened keys.
## `delimiter` (type: `string`):

Delimiter used in the CSV file.
## `expandLists` (type: `boolean`):

If true, lists will be expanded into multiple rows.

## Actor input object example

```json
{
  "jsonUrl": "https://services.nijmegen.nl/geoservices/extern_Mobiliteit/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=extern_Mobiliteit%3AMOB_TAXISTANDPLAATSEN&outputFormat=application%2Fjson",
  "jsonText": "{\"name\":\"John Doe\",\"age\":30,\"isStudent\":false,\"skills\":[\"JavaScript\",\"Python\",\"HTML\"],\"address\":{\"city\":\"New York\",\"zip\":\"10001\"}}",
  "separator": ".",
  "delimiter": ",",
  "expandLists": true
}
````

# 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 = {
    "jsonUrl": "https://services.nijmegen.nl/geoservices/extern_Mobiliteit/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=extern_Mobiliteit%3AMOB_TAXISTANDPLAATSEN&outputFormat=application%2Fjson",
    "jsonText": "{\"name\":\"John Doe\",\"age\":30,\"isStudent\":false,\"skills\":[\"JavaScript\",\"Python\",\"HTML\"],\"address\":{\"city\":\"New York\",\"zip\":\"10001\"}}"
};

// Run the Actor and wait for it to finish
const run = await client.actor("eloquent_mountain/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 = {
    "jsonUrl": "https://services.nijmegen.nl/geoservices/extern_Mobiliteit/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=extern_Mobiliteit%3AMOB_TAXISTANDPLAATSEN&outputFormat=application%2Fjson",
    "jsonText": "{\"name\":\"John Doe\",\"age\":30,\"isStudent\":false,\"skills\":[\"JavaScript\",\"Python\",\"HTML\"],\"address\":{\"city\":\"New York\",\"zip\":\"10001\"}}",
}

# Run the Actor and wait for it to finish
run = client.actor("eloquent_mountain/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 '{
  "jsonUrl": "https://services.nijmegen.nl/geoservices/extern_Mobiliteit/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=extern_Mobiliteit%3AMOB_TAXISTANDPLAATSEN&outputFormat=application%2Fjson",
  "jsonText": "{\\"name\\":\\"John Doe\\",\\"age\\":30,\\"isStudent\\":false,\\"skills\\":[\\"JavaScript\\",\\"Python\\",\\"HTML\\"],\\"address\\":{\\"city\\":\\"New York\\",\\"zip\\":\\"10001\\"}}"
}' |
apify call eloquent_mountain/json-to-csv-converter --silent --output-dataset

```

## MCP server setup

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