xtract.bot
POST /api/json-to-csv

Convert a JSON array of objects to CSV. Header row derived from object keys (union or first-record). Quotes only fields that need quoting.

Converts a JSON array of objects into a CSV document. Header behaviour: - `headerStrategy: "union"` (default): collect keys from every object, in first-seen order. Missing values become empty cells. - `headerStrategy: "first"`: take keys from the first object only. Extra keys in later objects are ignored. Values are stringified: numbers and booleans pass through as their JSON form; nested objects / arrays are JSON-stringified. Only fields that need quoting (those containing commas, quotes, or newlines) are quoted.

Inputs

NameTypeDefaultDescription
json*fileThe JSON document.

Response

Modes: text, json. Cache: yes (24h TTL).

Code samples

Built from the people example.

# Download or substitute the example input:
#   curl -O https://xtract.bot/examples/json-to-csv/people.json
JSON=$(base64 -w0 < people.json)

curl -X POST https://api.xtract.bot/api/json-to-csv \
  -H "Content-Type: application/json" \
  -H "Accept: text/plain" \
  -H "X-Account-Id: $XTRACT_ACCOUNT_ID" \
  -H "X-Api-Key: $XTRACT_API_KEY" \
  -d '{
  "json": "'"$JSON"'"
}'