Skip to main content
AI & LLM Essential

LLM Function Calling & Structured Outputs Schema Generator

Generate strict JSON Schema (Draft 7 / 2020-12), OpenAI Structured Outputs schemas, tool definitions, and Pydantic / Zod models for reliable LLM function calling.

Multi-Target Schema Synthesis: Generate compliant schemas for OpenAI Structured Outputs (response_format: json_schema), OpenAI Tools, Anthropic Claude Tools (input_schema), and Gemini FunctionDeclarations
Strict Mode Compliance: Automatically enforces additionalProperties: false, complete required arrays, and non-empty property descriptions required for deterministic LLM constrained decoding
Interactive Field Modeler: Visual schema editor supporting strings, numbers, integers, booleans, enums, nested objects, and arrays of typed items with description annotations
Bi-Directional Code Generation: Export schemas directly as TypeScript (Zod schemas, TypeBox, interfaces), Python (Pydantic v2 BaseModels), or raw RFC JSON Schema
Live Schema Validator: Test sample JSON outputs against your generated schema in real-time with instant validation and error highlighting
Local Privacy Sandbox: All schema authoring and code conversion occurs entirely within your browser with zero remote data collection
Sponsored Ad Zone

Clean, non-intrusive developer tools sponsor zone. Zero cumulative layout shift.

Comprehensive Technical Manual

Mastering JSON Schema for LLM Function Calling, Structured Outputs, and Tool Use

In-depth specifications, architectural mechanics, real-world code implementations, and industry best practices.

01

Understanding JSON Schema in LLM Function Calling & Structured Outputs

Traditional text generation from LLMs is non-deterministic, making automated extraction prone to syntax errors, missing fields, or hallucinated types. Modern AI providers (OpenAI, Anthropic, Google) solve this via Constrained Decoding—guiding the model's token sampling logits at every generation step using a formal grammar compiled from a JSON Schema. When constrained decoding is enabled, the LLM is mathematically incapable of generating tokens that violate the specified JSON Schema (RFC Draft-07 / 2020-12). This enables 100% reliable downstream parsing in microservices, database inserts, and automated workflows.

Implementation Example
// Example: RFC Draft-07 Strict JSON Schema for OpenAI Structured Outputs
{
  "name": "extract_user_profile",
  "strict": true,
  "schema": {
    "type": "object",
    "properties": {
      "name": { "type": "string", "description": "Full name of user" },
      "role": { "type": "string", "enum": ["admin", "editor", "viewer"] },
      "age": { "type": ["number", "null"] }
    },
    "required": ["name", "role", "age"],
    "additionalProperties": false
  }
}
02

OpenAI Strict Mode vs Anthropic Claude Tools vs Gemini Function Declarations

  • Different LLM providers implement JSON Schema with specific compatibility requirements:
  • OpenAI Structured Outputs (Strict Mode): Requires "additionalProperties": false on every object node, requires all defined keys to be listed in the "required" array (optional fields must use union types with null), and prohibits recursion or unsupported keywords like format.
  • Anthropic Claude Tool Use: Uses standard JSON Schema under input_schema, allowing flexible optional fields and custom tool descriptions.
  • Google Gemini Function Calling: Accepts OpenAPI 3.0 schema definitions under FunctionDeclaration.parameters.
  • WebCraftKit allows you to toggle compliance targets with a single click, instantly adapting the generated schema to provider constraints.
Implementation Example
// Anthropic Claude Tool Definition Format
{
  "name": "get_stock_quote",
  "description": "Fetch real-time ticker data for a NASDAQ/NYSE equity",
  "input_schema": {
    "type": "object",
    "properties": {
      "ticker": { "type": "string", "description": "Stock symbol (e.g. AAPL, NVDA)" }
    },
    "required": ["ticker"]
  }
}
03

Step-by-Step Tutorial: Building a Multi-Property LLM Tool Schema

Step 1: Set the Tool / Schema Name (e.g., extract_customer_order or weather_lookup) and write a clear, descriptive prompt in the schema description. Step 2: Add Top-Level Properties—Define property keys, select data types (string, number, boolean, array, object), and provide field-level descriptions that guide model extraction. Step 3: Configure Enums and Constraints—For categorical fields (e.g., status: ["pending", "shipped", "delivered"]), define enum values to constrain outputs. Step 4: Model Nested Structures—Create child objects or typed arrays (e.g., items: Array<{ sku: string, quantity: number, price: number }>). Step 5: Enable Strict Validation—Ensure all objects include additionalProperties: false and verify the required fields list. Step 6: Export Target Code—Select your runtime format (Zod for TypeScript, Pydantic for Python, or JSON Schema) and copy into your codebase.

Implementation Example
// TypeScript Zod Schema Equivalent
import { z } from 'zod';

export const OrderExtractionSchema = z.object({
  orderId: z.string().describe('Unique order reference code'),
  customer: z.object({
    email: z.string().email(),
    phone: z.string().nullable()
  }),
  items: z.array(z.object({
    sku: z.string(),
    quantity: z.number().int().positive(),
    price: z.number()
  })),
  priority: z.enum(['standard', 'express', 'overnight'])
});
04

Integrating Schemas with OpenAI SDK, Zod, and Pydantic v2

Modern applications rarely author raw JSON Schema strings by hand; instead, they define schemas using type-safe libraries like Zod (TypeScript) or Pydantic (Python) and convert them to provider schemas. Both the OpenAI SDK and Anthropic SDK offer native helpers to parse LLM outputs directly into typed objects with full runtime validation.

Implementation Example
// TypeScript: OpenAI Structured Outputs with zodResponseFormat
import OpenAI from 'openai';
import { zodResponseFormat } from 'openai/helpers/zod';
import { OrderExtractionSchema } from './schemas';

const openai = new OpenAI();

const completion = await openai.beta.chat.completions.parse({
  model: 'gpt-4o-2024-08-06',
  messages: [
    { role: 'system', content: 'Extract structured order data from customer text.' },
    { role: 'user', content: 'Customer bought 2x SKU-4090 ($1,599 each), deliver express to alex@test.com' }
  ],
  response_format: zodResponseFormat(OrderExtractionSchema, 'order_extraction')
});

const parsedOrder = completion.choices[0].message.parsed;
console.log(parsedOrder.customer.email); // Fully typed and validated!
05

Best Practices for Reliable Structured Extraction & Data Privacy

  • Use Semantic Property Descriptions: LLMs rely heavily on the description field of each property to understand context and edge cases. Treat descriptions as mini-prompts.
  • Avoid Excessively Deep Nesting: While schemas support arbitrary depth, keeping nesting to 2-3 levels improves reasoning speed and reduces token consumption.
  • Prefer Enums over Open Strings: Wherever values belong to a closed set (e.g., currencies, status codes, categories), define strict enums.
  • Client-Side Security: WebCraftKit operates exclusively in your browser sandbox. Your database entity names, internal API structures, and data types never leave your machine.
Implementation Example
// Python: OpenAI Structured Outputs with Pydantic v2
// from pydantic import BaseModel, Field
// from openai import OpenAI
// class UserSchema(BaseModel):
//     user_id: str = Field(description="UUID of the account")
//     role: str = Field(description="Role: admin, staff, or guest")
// client = OpenAI()
// response = client.beta.chat.completions.parse(
//     model="gpt-4o",
//     messages=[{"role": "user", "content": "Make admin user 123"}],
//     response_format=UserSchema
// )
Knowledge Base & Clarifications

Frequently Asked Questions: LLM Schema Builder

Got questions about how LLM Schema Builder operates, client-side cryptographic safety, or performance limits? Explore common answers below.

Complementary Utilities
View all in AI & LLM →