Two OpenAI formats
Generate either a flattened Responses function tool or the nested Chat Completions wrapper.
Start typing to search 227 tools.
Convert representative JSON arguments into an OpenAI function tool definition for the Responses API or Chat Completions.
JSON to OpenAI Function Schema converts a sample JSON value into a function tool definition. Choose the flattened tool format used by the Responses API or the nested function wrapper used by Chat Completions. The generated parameters object is a JSON Schema inferred from the sample.
Generation is deterministic and does not call an OpenAI model. Object properties are inferred recursively, observed fields are marked required, and generated objects use additionalProperties: false. These defaults provide a strict starting point, but a single example cannot identify optional arguments, field descriptions, enum choices, ranges, formats, or every valid array item.
get_weather.Focused controls, predictable output, and a workflow designed around this exact transformation.
Generate either a flattened Responses function tool or the nested Chat Completions wrapper.
Infer object, array, string, integer, number, boolean, and null nodes recursively.
Generated object schemas include required lists and additionalProperties false.
Build a reviewable schema without sending the sample to an OpenAI model.
Practical details about input, output, privacy, limits, and the best way to use this tool.
The Responses API uses a flattened function tool object. Chat Completions places name, description, parameters, and strict inside a nested function object.
No. It transforms the sample locally into JSON and does not execute a model request or function call.
The generated wrapper sets strict: true. OpenAI strict function calling expects a compatible parameter schema, including required properties and additionalProperties: false for object schemas.
Yes. The generator cannot infer optionality from one example. With strict mode enabled, every property must remain in required; represent an optional value with a nullable type. With strict disabled, you may remove optional names from required.
An empty array provides no item type. A non-empty array uses its first item as the initial item schema, so mixed arrays require manual editing.
No. Add descriptions and complete allowed-value rules manually so the model receives meaningful argument guidance.
The inferred value is wrapped in an object property named value because function arguments use an object parameter schema.
No. You must still send the correct API request, execute returned calls in your application, validate arguments, handle errors, and return tool results.
Learn JSON objects, arrays, value types, validation, formatting, parsing, API workflows, and common syntax errors.
The Responses API format places name, description, parameters, and strict beside type.
Sample JSON: {"location":"Kyiv","units":"celsius"}
Name: get_weather
Format: Responses API
Strict: enabled
{
"type": "function",
"name": "get_weather",
"description": "Get the current weather for a location",
"parameters": {
"type": "object",
"properties": {
"location": {"type": "string"},
"units": {"type": "string"}
},
"required": ["location", "units"],
"additionalProperties": false
},
"strict": true
}
Chat Completions nests the function definition inside the function property.
Sample JSON: {"order_id":"ord_42","include_items":true}
Name: get_order
Format: Chat Completions
Strict: enabled
{
"type": "function",
"function": {
"name": "get_order",
"description": "Generated function schema",
"parameters": {
"type": "object",
"properties": {
"order_id": {"type": "string"},
"include_items": {"type": "boolean"}
},
"required": ["order_id", "include_items"],
"additionalProperties": false
},
"strict": true
}
}
Nested objects are recursive, while an array item schema is inferred from the first item.
{
"customer": {"id": "cus_42", "vip": true},
"items": [{"sku": "A-10", "quantity": 2}]
}
customer → object customer.id → string customer.vip → boolean items → array items[0].sku → string items[0].quantity → integer
Both formats describe a tool with type: function, a programmatic name, a description, and a JSON Schema under parameters. The Responses API accepts these function fields directly on the tool object. Chat Completions uses a wrapper with the definition inside function. Select the format used by the endpoint and SDK code you will actually call.
The tool name identifies the application function; the description helps the model decide when that function is appropriate. Keep descriptions precise and distinguish tools that perform similar actions.
A sample object becomes an object parameter schema. Property names are preserved and values provide initial JSON types. Nested objects are inferred recursively. Integers remain integer, decimals become number, booleans remain boolean, and strings remain string. A scalar or array root is wrapped in a property named value.
Each object receives additionalProperties: false, and every observed property is added to required. This mirrors a closed sample, not necessarily the complete business contract.
With strict enabled, OpenAI uses schema-constrained function arguments. The schema must conform to the supported strict-mode subset. Closed object schemas and explicit required lists are important parts of that structure. If strict is disabled, generated arguments should still be validated by your application before execution.
Optional and nullable are different concepts. Optional controls whether a property must appear; nullable controls whether its value may be null. A single sample cannot infer either intention reliably. Edit required arrays and type unions based on the real contract.
The generator does not infer descriptions, formats, enum choices, defaults, numeric ranges, string patterns, array length rules, alternative object shapes, or recursive references. An empty array has no evidence for items. A mixed array is represented using its first item. A null sample identifies only null and does not reveal the intended non-null type.
The output does not make an API request, select a model, invoke the function, verify permissions, or execute application code. Function arguments are model output and must be validated before they reach databases, files, networks, payment systems, or other sensitive operations.
Generate the initial wrapper, then add field descriptions and real constraints. Validate supported schema rules with JSON Schema Validator. Compare the provider-neutral MCP shape using MCP Tool Schema Generator and inspect an MCP definition with MCP Schema Validator. Test valid, missing, extra, nullable, and boundary arguments against the exact OpenAI endpoint and SDK version used by the application.
Tool definitions contribute to request size. Estimate the completed schema with AI Token Counter, then project representative request volume with AI Token Cost Calculator.
Review the current OpenAI function calling guide and JSON Schema Draft 2020-12 before shipping a production integration.