Home / API docs / Data Format Conversion API
Math

Data Format Conversion API

POST /api/data/convert $0.005 per call USDC on Base · x402

Deterministic data-format conversion — the shape work an LLM cannot do reliably token-by-token. POST {data, from, to}: JSON, NDJSON, CSV, TSV, or a SQL INSERT dump in; any of the same out. Handles RFC 4180 quoting (commas, quotes, newlines in values), flattens nested objects to dot-notation columns, unions ragged records into a stable column set, and parses SQL string literals with '' and \' escapes. No AI, no network — same input, same bytes, every time.

Parameters

NameInDescription
databodyrequiredThe dataset as a string (up to ~4MB)
frombodyjson (default), ndjson, csv, tsv, or sql
tobodycsv (default), tsv, json, ndjson, or sql
flattenbodyFlatten nested objects to dot-notation columns (default true)
headerbodyCSV/TSV input has a header row (default true)
infer_typesbodyConvert numeric/boolean/null strings on input (default true); leading zeros stay strings
delimiterbodyOverride the delimiter for csv/tsv
tablebodyTable name when to=sql (default 'data')

Example request

curl -X POST "https://api.webbersites.com/api/data/convert" \
  -H "Content-Type: application/json" \
  -d '{"data":"[{\"id\":1,\"user\":{\"name\":\"Ann\"}},{\"id\":2,\"user\":{\"name\":\"Bo\"}}]","from":"json","to":"csv"}'
# first call returns 402 + payment requirements; an x402 client pays and retries automatically

Example response

{
    "from": "json",
    "to": "csv",
    "rows": 2,
    "columns": [
        "id",
        "user.name"
    ],
    "output": "id,user.name\n1,Ann\n2,Bo",
    "bytes": 26
}
MCP tool: post_data_convert — via npx -y webbersites-x402-mcp (local, key stays on your machine) or the remote endpoint https://api.webbersites.com/mcp.

How payment works

There is no signup and no API key. Call the endpoint; it replies 402 Payment Required with machine-readable payment requirements. Your client signs a USDC transfer authorization (EIP-3009, gasless) and retries with the X-PAYMENT header — @x402/fetch does this automatically. See the overview for a working snippet.