JSON KitJSON to OpenAI Function Schema

JSON to OpenAI Function Schema

Paste a JSON sample and get an OpenAI tool definition ready to drop into your API call.

Loading editor…
Loading editor…

Related Tools

What is an OpenAI Function Schema?

OpenAI's function calling (now called tools) lets you define structured outputs the model will populate. Instead of parsing free-form text, you describe what you need as a JSON Schema and the model returns a JSON object matching that shape — every time, reliably. This tool converts a sample JSON object into the exact schema format the OpenAI API expects.

How to Use This Tool

  1. Paste a sample JSON object with the shape you want the model to return. Use realistic values — the types are inferred from the values.
  2. Set the function name (snake_case recommended) and a clear description — the model uses both to decide when to call the function.
  3. Choose your output format: Tool definition, Parameters only, or Response format.
  4. Enable Strict mode for production — it guarantees exact schema adherence.
  5. Copy the output and paste it into your API call. Add descriptions to each property for best results.

Usage Example

import OpenAI from "openai";
const client = new OpenAI();

const response = await client.chat.completions.create({
  model: "gpt-4o",
  tools: [schema],          // ← paste generated schema here
  tool_choice: "auto",
  messages: [{ role: "user", content: "..." }],
});

const call = response.choices[0].message.tool_calls?.[0];
if (call?.function.name === "send_email") {
  const args = JSON.parse(call.function.arguments);
  // use args...
}

Three Output Modes Explained

Tool definition

{ type: 'function', function: {...} }

Full object for the tools[] array. The most common format — use this when defining callable functions.

Parameters only

{ type: 'object', properties: {...} }

Just the inner JSON Schema. Use when you're building the wrapper yourself or integrating with another SDK.

Response format

{ type: 'json_schema', json_schema: {...} }

Pass as response_format to force structured JSON output on any message without a function call.

Frequently Asked Questions

What is an OpenAI function / tool schema?
OpenAI's function calling (now called 'tools') lets you define structured outputs that the model will fill in. You describe a function with a name, description, and a JSON Schema for its parameters. The model then returns a structured JSON object matching that schema instead of free-form text — perfect for integrating AI into apps without regex-parsing responses.
What's the difference between 'Tool definition', 'Parameters only', and 'Response format'?
Tool definition is the full { type: 'function', function: {...} } object you pass in the tools array. Parameters only is just the inner JSON Schema for the parameters — useful if you're building the wrapper yourself. Response format is the { type: 'json_schema', json_schema: {...} } object you pass as response_format to force structured output on any message, without defining a callable function.
What is strict mode?
OpenAI Structured Outputs strict mode (strict: true) guarantees the model will always return JSON exactly matching your schema — no extra fields, no missing required fields. To use it, every object must have additionalProperties: false, every property must be in the required array, and no $ref or anyOf with more than 2 variants. Strict mode is ideal for production use; non-strict is fine for prototyping.
How does the tool handle null fields in my JSON?
A null value means the actual type is unknown — the tool uses 'string' as a placeholder. In strict mode it generates ["string", "null"] to allow null. You should replace the type with the actual expected type once you know it — for example, if sendAt can be an ISO datetime string or null, change it to { type: ["string", "null"] } and add a datetime format hint in the description.
Should I add descriptions to every parameter?
Yes, and they matter more than you might expect. GPT-4 uses parameter descriptions to understand what value to put in each field. A description like 'The ISO 8601 datetime when the email should be scheduled, or null to send immediately' gives the model far more to work with than an empty description. The 'Auto descriptions' toggle generates basic descriptions from key names as a starting point — always review and improve them.
What's the difference between function calling and response_format json_schema?
Function calling (tools) is for when you want the model to 'call' an action in your app — search a database, send an email, book a meeting. The model decides when to call the function based on the conversation. response_format json_schema is for when you always want a structured JSON response, regardless of context — extracting data from text, classification, transformations. Use tools for actions; use response_format for structured extraction.
How do I use the generated schema with the OpenAI SDK?
For tool mode: pass the schema in the tools array: client.chat.completions.create({ model: 'gpt-4o', tools: [<your schema>], messages: [...] }). For response_format: pass it as response_format: <your schema>. When the model calls your tool, check choices[0].message.tool_calls[0].function.arguments and parse the JSON.
Does this work with Anthropic Claude's tool use?
The JSON Schema format is very similar but the wrapper structure differs. Anthropic uses { name, description, input_schema: { type: 'object', properties: {...}, required: [...] } }. Select 'Parameters only' and wrap it manually: { name: 'my_function', description: '...', input_schema: <parameters schema> }.

About This Tool

JSON to OpenAI Function Schema is one of the most practically useful tools for AI application developers. Writing function schemas by hand is tedious and error-prone — especially getting the strict mode constraints right. This tool generates correct schemas in all three OpenAI formats from a simple JSON sample, runs 100% in your browser, and handles nested objects, arrays, null fields, and all primitive types. Pair it with the JSON to Zod Schema tool to also generate runtime validators for the arguments your function receives.