---
title: "Convert JSON to CSV"
method: POST
path: "/json-to-csv"
tags: ["Documents"]
---

# Convert JSON to CSV

`POST /json-to-csv`

## Request

- Base URL: `https://api.cofferdock.com`
- URL: `https://api.cofferdock.com/json-to-csv`
- Auth: API key in header `x-api-key`

Turns an array of objects into CSV text, quoting only where needed. The columns are every key found in any object, in order of first appearance; a value an object does not have stays empty. Up to 100,000 rows and 1,000 columns. If the data contains text you do not control (form answers, emails, web pages), set escape_formulas to true: text starting with = + - @ would otherwise be read as a formula when the CSV is opened in Excel or Google Sheets.

Costs 1 credit per call.

## Request body

- object
  - `data` object[], required: The rows to convert: a non-empty array of objects (up to 100000), e.g. [{"name":"Ana","age":30}]. The columns are every key found in any object (up to 1000), in order of first appearance; a value an object does not have stays empty.
  - `header` boolean: true (default) = write the column names as the first line; false = data rows only.
  - `delimiter` string: Field separator, exactly one character: "," (default), ";", "|" or a tab. Any other value is ignored and "," is used.
  - `escape_formulas` boolean: true = protect against spreadsheet formula injection: every text value (and every column name) that starts with =, +, -, @, a tab or a carriage return gets a single quote added in front, so "=1+1" is written as "'=1+1" and Excel or Google Sheets read it as plain text instead of running it as a formula. JSON numbers (-5 without quotes), booleans, null, objects and lists are never changed. false = write the text exactly as received. Use true whenever the data includes text you do not control (form answers, emails, web pages). Only the start of each text is protected: a text with a separator and "=" in the middle can still be split into a new cell by a program whose list separator differs from the delimiter, so choose the delimiter the reader expects or use json_to_excel.
  - `output` 'json' | 'csv': How to return the CSV: "json" (default: the CSV text in a "csv" field of the JSON response) or "csv" (the CSV itself as the response body, text/csv).

## Response `200`

Result.

- object
  - `success` boolean
  - `csv` string
  - `meta` object
    - `rows` integer
    - `columns` integer
    - `used` integer: Credits used this month, after this call.
    - `remaining` integer, nullable: Credits left this month (null = unlimited).
    - `unlimited` boolean

## Other responses

- `400`: Invalid input (nothing is charged).
- `401`: Missing or invalid API key.
- `403`: Email not verified.
- `429`: Monthly credit limit reached, or too many requests per minute for this key (see Retry-After).
- `503`: Server busy (queue full). Retry after the seconds in the Retry-After header.

---

[API](https://skmtc.dev/cofferdock/apis/cofferdock-api.md) · [All operations](https://skmtc.dev/cofferdock/apis/cofferdock-api/llms.txt) · [OpenAPI document](https://skmtc.dev/cofferdock/apis/cofferdock-api/revisions/b57aa000d33a?raw)
