Skip to main content

Squillify development is paused indefinitely. Read why, and discover what this experiment achieved. Read the story

MicroSkills Reference

JSON Schema to TypeScript

schema.convert_json_schema_to_typescript

ProductionBounded custom (Class B)Deterministicstrictfastv1.0.0
No network

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

Note
One JSON Schema in, one block of TypeScript declarations out — with an honest list of everything the type system could not carry over.

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

IdempotentRetry safeStreaming supportedFile input supportedRequires external service

Capabilities

generationparsing

Cost & billing

Flat rate per invocation

MetercallsBillable onsuccessCost per call1 credit

File handling

Accepts file_refProduces file_refMax input1.9 MB

How we handle your data

Sensitive output possible
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.

Read the Microskill Data Handling Policy

Input schema

FieldTypeRequiredDescription
schemaobjectYesJSON Schema to emit types from; extra keys are schema keywords and every $ref must stay local to this document. — unconstrained RFC 8259 JSON items.
rootTypeNamestringNoPreferred root declaration name; omit it for Root.
stylestringNoDeclaration shape for an object root; omit it for interface.
strictNullabilitybooleanNoAccepted for compatibility and does not change emission today; omit it for true.
additionalPropertiesModestringNoWhat to do when the schema is silent about extra keys; omit it for unknown.
emitCommentsbooleanNoCopy schema descriptions into JSDoc comments; omit it for true.

Output schema

FieldTypeRequiredDescription
typescriptstringYesGenerated TypeScript source with one exported declaration per type and a trailing newline.
emittedRootTypeNamestringYesRoot name actually used after sanitising rootTypeName and settling clashes.
declarationsarrayYesDeclaration names in source order, 0 through 500 strings, defs first then the root then nested object types.
lossybooleanYesTrue when at least one construct was emitted as unknown.
warningsarrayYesNon-fatal advisory notices as 0 through 100 strings, each one sentence long; empty when nothing was worth flagging.

API contract

POST /v1/execute
curl
curl -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"}}'
Integrations
TypeScript SDK
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

CodeHTTPRetryableDescription
VALIDATION_ERROR400NoThe request payload failed schema validation.
UNAUTHORIZED401NoMissing or invalid API key.
SKILL_NOT_ACCESSIBLE403NoThe API key is not granted access to this skill.
SKILL_NOT_AVAILABLE_FOR_PLAN403NoThis skill is not included in your current plan.
PLAN_ELIGIBILITY_UNAVAILABLE503YesPlan eligibility could not be decided. Retry after backoff.
SKILL_NOT_FOUND404NoThe requested skill or version does not exist.
TENANT_RATE_LIMITED429YesRequest rate limit exceeded. Retry after backoff.
QUOTA_EXCEEDED429YesPlan quota exhausted. Retryable once the quota period resets.
EXECUTION_TIMEOUT504YesExecution exceeded the allowed time budget.

Other limits

LimitValue
Recommended inline bytes32 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)

Request bodyjson
{
  "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

Inputjson
{
  "rootTypeName": "OrderLine",
  "schema": {
    "type": "object",
    "properties": {
      "sku": {
        "type": "string",
        "description": "Stock keeping unit"
      },
      "quantity": {
        "type": "integer"
      }
    },
    "required": [
      "sku"
    ]
  }
}
Expected outputjson
{
  "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

Inputjson
{
  "schema": {
    "type": "string",
    "enum": [
      "draft",
      "issued",
      "paid"
    ]
  },
  "rootTypeName": "InvoiceStatus",
  "emitComments": false
}
Expected outputjson
{
  "warnings": [],
  "lossy": false,
  "emittedRootTypeName": "InvoiceStatus",
  "declarations": [
    "InvoiceStatus"
  ],
  "typescript": "export type InvoiceStatus = \"draft\" | \"issued\" | \"paid\";\n"
}
  • 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

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.

Tags

typescriptjsonschemageneration