JSON Schema · TypeScript · Zod

Schema Generator API

Paste a JSON example, get a JSON Schema or TypeScript interface back instantly. No more writing schemas by hand.

The problem it solves

You have example data. You need a schema. You shouldn't have to write it manually — field by field, type by type, nested object by nested object.

This is especially painful when validating LLM output, documenting undocumented APIs, or bootstrapping TypeScript interfaces from third-party responses.

How it works

Request

POST /api/tools/schema-generator

{
  "input": {
    "userId": "usr_123",
    "email": "user@example.com",
    "plan": "pro",
    "createdAt": "2024-01-15T10:30:00Z",
    "active": true
  },
  "format": "typescript"
}

Response

{
  "schema": "interface Output {\n
    userId: string;\n
    email: string;\n
    plan: string;\n
    createdAt: string;\n
    active: boolean;\n
  }",
  "format": "typescript"
}

Switch format to "json-schema" for full JSON Schema draft-07 output with format inference, required fields, and nested object support.

What it detects automatically

Email & date formats

Infers format: "email" and format: "date-time" from values

Nested objects & arrays

Recursively generates schemas for complex structures

integer vs number

Correctly distinguishes integer and floating-point fields

Required fields

Populates required array based on present keys

TypeScript SDK

import { AgentToolbelt } from "agent-toolbelt";

const toolbelt = new AgentToolbelt({ apiKey: process.env.TOOLBELT_KEY });

// Validate LLM output against a generated schema
const llmOutput = await callLLM(prompt);
const { schema } = await toolbelt.schemaGenerator({
  input: exampleOutput,
  format: "json-schema",
});

const valid = ajv.validate(schema, llmOutput);
if (!valid) throw new Error("LLM output didn't match expected shape");

Pricing

Fractions of a cent per call

Get API Key →

More tools

Part of Agent Toolbelt — 14 focused API tools for AI developers