# POST /convert/csv-json: $0.001 per call

Convert CSV to JSON or JSON to CSV. POST {"csv": "..."} for rows as objects (delimiter detected, quoted fields and line breaks handled, numbers and booleans typed, leading zeros kept), or {"json": [...]} for RFC 4180 CSV (nested objects flattened as a.b). Up to 1 MB and 20,000 rows.

- **Price:** $0.001 in USDC, the same on Base, Solana, Polygon, Arbitrum. Failed calls are never charged.
- **Free trial:** yes, 20 free calls a day from Claude, Cursor or any MCP client ([set-up](/mcp/setup)).
- **Answers cached for:** not cached
- **Data sources:** computed locally
- **Lane:** Developer toolkit ([OpenAPI](/openapi/devkit.json))
- **Live health:** [status page](/status)

## Free sample

See an answer for the demo input first, free (no payment, 10 a minute): [https://aayatai.com/sample/csv-json](/sample/csv-json). It is a stored real answer when we have one, otherwise an example marked `"kind": "illustrative"`.

```bash
curl "https://aayatai.com/sample/csv-json"
```

## 1. See the price (free)

Call it without paying: you get `402 Payment Required` and a `PAYMENT-REQUIRED` header with the exact price and where to pay.

```bash
curl -i -X POST https://aayatai.com/convert/csv-json -H "content-type: application/json" -d '{"csv":"id,name,postcode,active\n007,\"Acme, Ltd\",SW1A 1AA,true\n12,Beta,,false\n"}'
```

## 2. Pay and call (TypeScript)

```bash
npm install @x402/fetch @x402/evm viem
```

```ts
import { wrapFetchWithPaymentFromConfig } from "@x402/fetch";
import { ExactEvmScheme } from "@x402/evm";
import { privateKeyToAccount } from "viem/accounts";

// A wallet used only by your agent, holding a little USDC on Base.
const account = privateKeyToAccount(process.env.WALLET_PRIVATE_KEY as `0x${string}`);
const pay = wrapFetchWithPaymentFromConfig(fetch, {
  schemes: [{ network: "eip155:8453", client: new ExactEvmScheme(account) }],
});

const res = await pay("https://aayatai.com/convert/csv-json", {
  method: "POST",
  headers: { "content-type": "application/json" },
  body: JSON.stringify({"csv":"id,name,postcode,active\n007,\"Acme, Ltd\",SW1A 1AA,true\n12,Beta,,false\n"}),
});
console.log(await res.json());
```

## 3. Or as an MCP tool

```ts
// MCP server: https://aayatai.com/mcp (Streamable HTTP). With the x402 MCP client (see /start):
const result = await client.callTool("csv-json", {"csv":"id,name,postcode,active\n007,\"Acme, Ltd\",SW1A 1AA,true\n12,Beta,,false\n"});
```

## Inputs

- `csv` (string): CSV text to turn into JSON. Give csv or json, not both.
- `json` (array): Array of objects (or of arrays) to turn into CSV. A JSON string is accepted too.
- `delimiter` (string; one of `auto`, `,`, `;`, `	`, `|`; default `auto`): Field separator (auto-detected for CSV input; comma for CSV output).
- `header` (boolean; default `true`): CSV has (or should have) a header row.
- `types` (boolean; default `true`): CSV → JSON: turn numbers, true/false and empty cells into numbers, booleans and null.

Bad inputs are rejected with HTTP 400 before any payment is asked for.

## Example answer

Example only: the shape of an answer, with placeholder addresses and made-up figures. It is not data about any real token or wallet; call the service (or its free sample) for real results.

```json
{
  "direction": "csv-to-json",
  "rows": 2,
  "columns": [
    "id",
    "name",
    "postcode",
    "active"
  ],
  "delimiter": ",",
  "json": [
    {
      "id": "007",
      "name": "Acme, Ltd",
      "postcode": "SW1A 1AA",
      "active": true
    },
    {
      "id": 12,
      "name": "Beta",
      "postcode": null,
      "active": false
    }
  ],
  "csv": null,
  "warnings": []
}
```

## Related

- [GET /http/security-headers](/services/security-headers) ($0.003): Security audit of a website's HTTP headers, graded A–F with a fix per finding: HTTPS and the http→https redirect, HSTS, Content-Security-Policy strength, clickj

New here? [Getting started in 60 seconds](/start). All services: [Aayat AI](/).