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
| Field | Type | Required | What it is |
|---|---|---|---|
json | any | Yes | JSON string or object |
export | boolean | No | — |
root_name | string | No | — |
Output fields
How reliably each field appears in a successful answer.
| Field | Type | Appears |
|---|---|---|
root_type | string | Always (present in every successful answer) |
typescript | string | Always (present in every successful answer) |
interface_count | integer | Always (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
}' {
"tool": "strale_execute",
"arguments": {
"slug": "json-to-typescript",
"inputs": {
"json": "{\"name\": \"Test\", \"value\": 42}"
},
"max_price_cents": 5
}
} import { Strale } from "straleio";
const strale = new Strale({ apiKey: process.env.STRALE_API_KEY! });
const result = await strale.do({
capability_slug: "json-to-typescript",
inputs: {
"json": "{\"name\": \"Test\", \"value\": 42}"
},
max_price_cents: 5,
}); import os
from straleio import Strale, DoRequest
strale = Strale(api_key=os.environ["STRALE_API_KEY"])
result = strale.do(DoRequest(
capability_slug="json-to-typescript",
inputs={
"json": "{\"name\": \"Test\", \"value\": 42}",
},
max_price_cents=5,
)) # No account. The first request answers 402 with the price in USDC;
# an x402 client pays it from your wallet and repeats the request.
curl -i 'https://api.strale.io/x402/v2/json-to-typescript?json=%7B%22name%22%3A+%22Test%22%2C+%22value%22%3A+42%7D' 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
Related tools
- Agent Trace Analysis €0.20
- API Docs Generator €0.20
- API Mock Responses €0.05
- Changelog Generator €0.03
- Code Converter €0.05
- Commit Message Generator €0.05