---
title: "Use this when you need to convert tabular data between JSON (array of objects), CSV, TSV, and XML instead of hand-transforming it."
method: POST
path: "/v1/convert_data"
tags: ["data"]
---

# Use this when you need to convert tabular data between JSON (array of objects), CSV, TSV, and XML instead of hand-transforming it.

`POST /v1/convert_data`

## Request

- Base URL: `https://api.clean.tools`
- URL: `https://api.clean.tools/v1/convert_data`
- Auth: none declared

Use this when you need to convert tabular data between JSON (array of objects), CSV, TSV, and XML instead of hand-transforming it. Deterministic: same input, same output. Handles quoted CSV fields (embedded commas, escaped "" quotes), flattens nested objects into dotted keys (b.x), and takes the union of keys across all rows so ragged data still lines up in columns. CSV/TSV input needs a header row plus at least one data row; JSON input must be an array of objects. Example: {from:'csv', to:'json'} on "name,age\nAda,36\nGrace,45" -> rowCount 2 and an output JSON array of two objects. Returns the input/output formats, the parsed row count, and the serialized output document as a string.

## Request body

- object
  - `data` string, required: The source document as text.
  - `from` 'json' | 'csv' | 'tsv' | 'xml', required: Input format.
  - `to` 'json' | 'csv' | 'tsv' | 'xml', required: Output format.

## Response `200`

Structured tool result.

- object
  - `tool` string
  - `result` object
    - `from` 'json' | 'csv' | 'tsv' | 'xml', required: Echo of the input format.
    - `to` 'json' | 'csv' | 'tsv' | 'xml', required: Echo of the target format.
    - `rowCount` integer, required: Number of data rows (objects) parsed from the input.
    - `output` string, required: The converted document as text in the target format (JSON is pretty-printed with 2-space indent).

## Other responses

- `400`: Invalid input or the tool reported an error.
- `413`: Request body exceeds the 128 KB limit.
- `429`: Rate limit exceeded; the response carries Retry-After and RateLimit-* headers — honor them and add jitter.

---

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