DevTools Logo

AI Function Calling Schema Generator

AI Function Calling Schema Generator

Turn a TypeScript interface into OpenAI, Anthropic, or Gemini tool JSON.

Runs in your browser
Try an example

TypeScript interface

Tool schema

Paste a TypeScript interface to generate a schema

Results update as you type. Nothing leaves your browser.

Examples

Optional and union handling

Input
generateFunctionCallingSchema("interface SearchArgs { query: string; limit?: number; mode: \"fast\" | \"deep\" }")
Output
{ required: ["query", "mode"], properties: { mode: { enum: ["fast", "deep"] } } }

The ? field drops from required while the pure literal union collapses to an enum.

Gemini envelope

Input
generateFunctionCallingSchema("interface Ping { value: number }", "gemini")
Output
{ functionDeclarations: [{ name: "Ping", parameters: { type: "object", ... } }] }

The same parameters object nests under functionDeclarations with additionalProperties false.

About this tool

Function Calling Schema Generator turns TypeScript shapes into tool schemas with generateFunctionCallingSchema(source, format): interface or object type declarations parse into a ParsedFunctionSchema with name, optional description, and a parameters object carrying properties, required, and additionalProperties false.

Documentation transfers automatically: leading /** */ summaries become the function description, @param tags and inline property comments become per-property descriptions, optional ? fields stay out of required, and nested inline objects, arrays, primitives, and literal unions map to JSON Schema (pure string/number/boolean unions become enum, mixed unions become anyOf).

Three target envelopes ship deterministically: openai wraps as { type: function, function: { name, description, parameters, strict: true } }, anthropic as { name, description, input_schema }, and gemini as { functionDeclarations: [{ name, description, parameters }] }, with invalid input returning schema null plus an error.

How to use this tool

  1. Paste the interface

    Provide an interface or object type — JSDoc summaries and @param lines ride along as descriptions.

  2. Pick the target

    Choose openai, anthropic, or gemini to switch the envelope around the same parameters object.

  3. Validate

    Check required excludes ? fields, unions show enum or anyOf, and empty input surfaces an error.

Use cases

Wiring OpenAI function calling

Convert request interfaces into strict function tools with descriptions intact.

Targeting Claude tool use

Reuse the same interface for Anthropic input_schema envelopes.

Targeting Gemini declarations

Emit functionDeclarations payloads for Vertex and AI Studio tool config.

Common mistakes

Mistake:Expecting ? fields in required.

Fix:Optional properties are excluded by design — only bare name: type entries land in required.

Mistake:Reading every union as an enum.

Fix:Only all-literal unions become enum; mixed or object unions emit anyOf branches instead.

Frequently asked questions

What does this tool do?

It parses TypeScript interfaces with generateFunctionCallingSchema into JSON Schema parameters (properties, required, additionalProperties false) wrapped for openai, anthropic (input_schema), or gemini (functionDeclarations) targets.

How are descriptions, optionals, and unions handled?

JSDoc summaries and @param tags become descriptions, ? fields drop from required, pure literal unions become enum while mixed unions become anyOf, and OpenAI output sets strict true.

Is my interface uploaded or stored?

No. Type parsing and envelope building run entirely in your browser.

Why is schema null, or required missing a field?

Non-interface or empty inputs return schema null with an explanatory error, and optional ? properties are excluded from required by design.

References & standards