Convert JSON or YAML to JSON, YAML, or TypeScript interfaces. Input format is auto-detected unless you set inputFormat. Options match the browser tool.
POST /api/v1/tools/json-yaml-typescript
Cost: 1 credit per successful request, taken from your account balance and shared by every token. A failed request is not charged.
Request body
| Field | Description |
|---|---|
input | Required. The JSON or YAML text to convert. Max 1 MB. |
output | Required. One of json, yaml, or typescript. |
inputFormat | Optional. json or yaml. Omit to auto-detect, as on the page. |
inferOptionalFields | Optional boolean. Mark null or missing keys optional in TypeScript. Default true. |
camelCaseKeys | Optional boolean. Emit TypeScript property names in camelCase. Default false. |
readonlyProperties | Optional boolean. Prefix TypeScript properties with readonly. Default false. |
indentSize | Optional. 2 or 4 spaces. Default 2. |
rootName | Optional. Root TypeScript interface name. Must be a legal identifier. Default Root. |
Example
curl https://wapgee.com/api/v1/tools/json-yaml-typescript \
-H "Authorization: Bearer wpg_your_token" \
-H "Content-Type: application/json" \
-d '{"input":"{\"name\":\"wapgee\"}","output":"yaml"}'A successful call returns:
{
"success": true,
"output": "name: wapgee\n",
"inputFormat": "json",
"outputFormat": "yaml"
}