# JSON CSV Markdown Table Converter and Validator (`chun_yung_lo/json-csv-markdown-converter`) Actor

Convert JSON to CSV, CSV to JSON, and either one to a GitHub-style Markdown table. Flattens nested JSON into dot-notation columns and validates JSON or CSV with line-level error messages.

- **URL**: https://apify.com/chun_yung_lo/json-csv-markdown-converter.md
- **Developed by:** [Chun-Yung Yong Lo](https://apify.com/chun_yung_lo) (community)
- **Categories:** Developer tools, MCP servers
- **Features:** Limited permissions, Single-tenant, Server interface
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.50 / 1,000 conversion or validations

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

Learn more: https://docs.apify.com/actors/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 CSV Markdown Table Converter and Validator

One focused tool for moving tabular data between the three formats people paste into tickets, spreadsheets, docs and LLM prompts:

- **JSON to CSV**: nested objects and arrays are flattened into dot-notation columns (`user.name`, `tags.0`).
- **CSV to JSON**: an array of objects keyed by the header row.
- **JSON or CSV to Markdown table**: a GitHub-flavoured table, with pipes escaped and line breaks turned into `<br>`.
- **Validate**: checks JSON syntax (with line and column) or CSV structure (ragged rows, duplicate headers, broken quotes). Invalid data is reported, and the run does not fail.

It also runs as an MCP server, so AI agents can call it as a tool.

### Input example

```json
{
  "data": "[{\"name\": \"Alice\", \"age\": 30, \"address\": {\"city\": \"Paris\"}}, {\"name\": \"Bob\", \"age\": 25}]",
  "inputFormat": "auto",
  "outputFormat": "csv",
  "delimiter": ",",
  "flattenNested": true
}
```

| Field | Meaning |
|---|---|
| `data` | JSON or CSV text (required) |
| `inputFormat` | `auto` (default), `json`, `csv` |
| `outputFormat` | `csv` (default), `json`, `markdown`, `validate` |
| `delimiter` | `,` (default), `;`, `tab`, `\|`. Used for reading and writing CSV |
| `flattenNested` | `true` (default) flattens nested JSON; `false` keeps nested values as JSON text |

### Output example

Each run produces one dataset item:

```json
{
  "inputFormat": "json",
  "outputFormat": "csv",
  "valid": true,
  "rowCount": 2,
  "columns": ["name", "age", "address.city"],
  "error": "",
  "output": "name,age,address.city\nAlice,30,Paris\nBob,25,"
}
```

Validation of broken CSV (`outputFormat: validate`):

```json
{ "valid": false, "rowCount": 2, "error": "line 3 has 1 fields, expected 2", "output": "" }
```

JSON errors read like `Invalid JSON: <parser message> at line L column C`. The exact parser message comes from Python's built-in `json` module and can differ slightly between Python versions.

### Pricing

US$0.0015 per conversion or validation (one event per run), plus standard Apify platform usage.

### Limits

- Up to 5,000,000 characters of input per run.
- CSV values are kept as strings. There is no type guessing, so `"30"` stays `"30"` in JSON output.
- JSON input must be an array of objects, a single object, or an array of plain values (these go into a `value` column).
- If a flattened key collides with a literal key (for example `"a.b"` and `{"a": {"b": ...}}`), the later value wins.
- Validation reports up to 20 row problems.
- When converting, invalid input fails the run with a clear message. Use `validate` to inspect the problems instead.

### Credits

Markdown tables are rendered with [python-tabulate](https://github.com/astanin/python-tabulate) by Sergey Astanin, MIT License. JSON and CSV handling uses the Python standard library.

# Actor input Schema

## `data` (type: `string`):

The JSON (an array of objects, a single object, or an array of values) or CSV text to convert or validate. The first CSV line is the header.

## `inputFormat` (type: `string`):

auto treats text starting with \[ or { as JSON and anything else as CSV.

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

csv, json or markdown converts the data. validate only checks it and reports errors without failing the run.

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

Delimiter used to read CSV input and to write CSV output.

## `flattenNested` (type: `boolean`):

Turn nested objects and arrays into dot-notation columns such as user.name or tags.0. When off, nested values are kept as JSON text in CSV and Markdown.

## Actor input object example

```json
{
  "data": "[{\"name\": \"Alice\", \"age\": 30, \"address\": {\"city\": \"Paris\"}}, {\"name\": \"Bob\", \"age\": 25}]",
  "inputFormat": "auto",
  "outputFormat": "csv",
  "delimiter": ",",
  "flattenNested": true
}
```

# Actor output Schema

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

One row per processed input

# 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 = {
    "data": "[{\"name\": \"Alice\", \"age\": 30, \"address\": {\"city\": \"Paris\"}}, {\"name\": \"Bob\", \"age\": 25}]"
};

// Run the Actor and wait for it to finish
const run = await client.actor("chun_yung_lo/json-csv-markdown-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 = { "data": "[{\"name\": \"Alice\", \"age\": 30, \"address\": {\"city\": \"Paris\"}}, {\"name\": \"Bob\", \"age\": 25}]" }

# Run the Actor and wait for it to finish
run = client.actor("chun_yung_lo/json-csv-markdown-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 '{
  "data": "[{\\"name\\": \\"Alice\\", \\"age\\": 30, \\"address\\": {\\"city\\": \\"Paris\\"}}, {\\"name\\": \\"Bob\\", \\"age\\": 25}]"
}' |
apify call chun_yung_lo/json-csv-markdown-converter --silent --output-dataset

```

## MCP server setup

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