JSON to TypeScript

Turn JSON into TypeScript interfaces. Handles nested objects, arrays and optional fields, and spots date strings and UUIDs.

Pay by wallet (x402) json-to-typescript

Example

Example answer
{
  "root_type": "Root",
  "typescript": "export interface Root {\n  name: string;\n  value: number;\n}",
  "interface_count": 1
}

Inputs

FieldTypeRequiredWhat it is
jsonanyYesJSON string or object
exportbooleanNo—
root_namestringNo—

Output fields

How reliably each field appears in a successful answer.

FieldTypeAppears
root_typestringAlways (present in every successful answer)
typescriptstringAlways (present in every successful answer)
interface_countintegerAlways (present in every successful answer)

How to call it

The same tool through each route. MCP clients reach it through Strale’s server at https://api.strale.io/mcp; the call below is what the agent sends.

# Needs an API key. max_price_cents caps what this call may cost.
curl -X POST https://api.strale.io/v1/do \
  -H "Authorization: Bearer $STRALE_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "capability_slug": "json-to-typescript",
    "inputs": {
      "json": "{\"name\": \"Test\", \"value\": 42}"
    },
    "max_price_cents": 5
  }'

Limitations

  • One sample may miss union types and optional fields

    Infers TypeScript interfaces from JSON samples — union types and optional fields may not be correctly detected from a single sample

    What to do instead: Provide multiple JSON samples with varying shapes to produce more accurate optional and union type inference