JSON Schema to TypeScript
schema.convert_json_schema_to_typescript
Overview
You send a JSON Schema and get TypeScript source back, byte-identical every time for the same input. Nested objects become their own named types, enums and const become string-literal unions, anyOf and oneOf become unions, allOf becomes an intersection, and a local $ref into $defs or definitions points at the type we generated for it. Whatever TypeScript cannot express comes out as unknown, flagged by lossy and named in warnings — we never quietly invent a type. There is no runtime validator in the output, so pair it with schema.validate_json if you need checks at runtime.
Hand-written types drift away from the contract the moment someone edits the schema. You regenerate them in one call, with no build toolchain to install.
Reliability
Deterministic: the same schema and the same options always give you byte-identical source. Read lossy and warnings before you trust the result — anything TypeScript cannot carry is reported, never silently dropped. We reject the call, and an unchanged retry will not help, when schema is absent or not an object, when style is anything other than interface or type, or when rootTypeName, additionalPropertiesMode, strictNullability or emitComments arrive with the wrong JSON type. Fix the field we name and call again.
Context footprint
You get the source, the declaration names, and at most 100 warnings; nesting stops at 32 levels and 500 declarations. A successful call costs 1 execution credit.
When to use it
When you have a JSON Schema and want TypeScript types you can paste straight into a client.
When the schema depends on remote references or conditional subschemas, or when what you really need is validation at runtime.
Scope
Non-goals
- We never download a $ref from another document; keep them local
- We never compile, format, or run the TypeScript we hand you
- We never emit a runtime validator, only compile-time types
- We cover a subset, not a full converter: if and then and else, dependentSchemas, patternProperties, prefixItems nuances, and pattern or format constraints come out as unknown with a warning rather than a clever approximation
Properties
Capabilities
Cost & billing
Flat rate per invocation
File handling
How we handle your data
What this means
This skill may receive sensitive content and may return submitted, transformed, extracted, or reformatted content.
Squillify guarantees
- Runs inside Squillify
- This skill runs inside Squillify.
- Payloads are not sent to an external service by this skill.
- Squillify does not permanently store submitted payloads.
- Telemetry records metadata only, not submitted content.
- Submitted payloads are not used for training.
- Submitted payloads are not reviewed by humans.
- This skill does not target sensitive data.
- The response may contain submitted or transformed content.
Your responsibility
Squillify does not determine whether submitted content is sensitive. Your application is responsible for deciding what data it is allowed to submit. Your application is responsible for securing the response.
Input schema
| Field | Type | Required | Description |
|---|---|---|---|
| schema | object | Yes | JSON Schema to emit types from; extra keys are schema keywords and every $ref must stay local to this document. — unconstrained RFC 8259 JSON items. |
| rootTypeName | string | No | Preferred root declaration name; omit it for Root. |
| style | string | No | Declaration shape for an object root; omit it for interface. |
| strictNullability | boolean | No | Accepted for compatibility and does not change emission today; omit it for true. |
| additionalPropertiesMode | string | No | What to do when the schema is silent about extra keys; omit it for unknown. |
| emitComments | boolean | No | Copy schema descriptions into JSDoc comments; omit it for true. |
Output schema
| Field | Type | Required | Description |
|---|---|---|---|
| typescript | string | Yes | Generated TypeScript source with one exported declaration per type and a trailing newline. |
| emittedRootTypeName | string | Yes | Root name actually used after sanitising rootTypeName and settling clashes. |
| declarations | array | Yes | Declaration names in source order, 0 through 500 strings, defs first then the root then nested object types. |
| lossy | boolean | Yes | True when at least one construct was emitted as unknown. |
| warnings | array | Yes | Non-fatal advisory notices as 0 through 100 strings, each one sentence long; empty when nothing was worth flagging. |
API contract
POST /v1/executecurl -sS -X POST "$BASE/v1/execute" -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' -d '{"skillKey":"schema.convert_json_schema_to_typescript","input":{"schema":{"type":"object","properties":{"sku":{"type":"string"},"quantity":{"type":"integer"}},"required":["sku"]},"rootTypeName":"OrderLine","style":"interface","additionalPropertiesMode":"indexSignature"}}'import { Squillify } from "@squillify/sdk";
const sq = new Squillify({ apiKey: process.env.SQUILLIFY_API_KEY });
const { output } = await sq.execute("schema.convert_json_schema_to_typescript", {"rootTypeName":"OrderLine","schema":{"type":"object","properties":{"sku":{"type":"string","description":"Stock keeping unit"},"quantity":{"type":"integer"}},"required":["sku"]}});Errors
| Code | HTTP | Retryable | Description |
|---|---|---|---|
| VALIDATION_ERROR | 400 | No | The request payload failed schema validation. |
| UNAUTHORIZED | 401 | No | Missing or invalid API key. |
| SKILL_NOT_ACCESSIBLE | 403 | No | The API key is not granted access to this skill. |
| SKILL_NOT_AVAILABLE_FOR_PLAN | 403 | No | This skill is not included in your current plan. |
| PLAN_ELIGIBILITY_UNAVAILABLE | 503 | Yes | Plan eligibility could not be decided. Retry after backoff. |
| SKILL_NOT_FOUND | 404 | No | The requested skill or version does not exist. |
| TENANT_RATE_LIMITED | 429 | Yes | Request rate limit exceeded. Retry after backoff. |
| QUOTA_EXCEEDED | 429 | Yes | Plan quota exhausted. Retryable once the quota period resets. |
| EXECUTION_TIMEOUT | 504 | Yes | Execution exceeded the allowed time budget. |
Other limits
| Limit | Value |
|---|---|
| Recommended inline bytes | 32 KiB |
Limitations
- We never download a $ref from another document; keep them local
- We never compile, format, or run the TypeScript we hand you
- We never emit a runtime validator, only compile-time types
- We cover a subset, not a full converter: if and then and else, dependentSchemas, patternProperties, prefixItems nuances, and pattern or format constraints come out as unknown with a warning rather than a clever approximation
- Schemas that lean on remote references or conditional subschemas
- Getting a runtime validator rather than compile-time types
- Producing types for a language other than TypeScript
How to call
POST /v1/execute (requires authentication)
{
"skillKey": "schema.convert_json_schema_to_typescript",
"input": {
"rootTypeName": "OrderLine",
"schema": {
"type": "object",
"properties": {
"sku": {
"type": "string",
"description": "Stock keeping unit"
},
"quantity": {
"type": "integer"
}
},
"required": [
"sku"
]
}
}
}Examples
Order line schema to an interface
{
"rootTypeName": "OrderLine",
"schema": {
"type": "object",
"properties": {
"sku": {
"type": "string",
"description": "Stock keeping unit"
},
"quantity": {
"type": "integer"
}
},
"required": [
"sku"
]
}
}{
"warnings": [],
"lossy": false,
"emittedRootTypeName": "OrderLine",
"declarations": [
"OrderLine"
],
"typescript": "export interface OrderLine {\n /** Stock keeping unit */\n sku: string;\n quantity?: number;\n}\n"
}Status enum to a string-literal union
{
"schema": {
"type": "string",
"enum": [
"draft",
"issued",
"paid"
]
},
"rootTypeName": "InvoiceStatus",
"emitComments": false
}{
"warnings": [],
"lossy": false,
"emittedRootTypeName": "InvoiceStatus",
"declarations": [
"InvoiceStatus"
],
"typescript": "export type InvoiceStatus = \"draft\" | \"issued\" | \"paid\";\n"
}Recommended use cases
- Generate client-side types from the JSON Schema a partner publishes
- Scaffold TypeScript models for a config file you already describe with a schema
- Keep front-end types in step with a contract without adding a build toolchain
Avoid for
- Schemas that lean on remote references or conditional subschemas
- Getting a runtime validator rather than compile-time types
- Producing types for a language other than TypeScript
Related skills
Composable with
Safety & privacy
- Runs without calling any external service.
- Your payloads are never stored permanently.
- Telemetry captures metadata only — never your payload contents.
- We never train models on your payloads.
- No human reviews your payloads.