OpenAPI to Tool Schemas

Processed locally

Convert OpenAPI or Swagger into Zod, JSON Schema, OpenAI function tools, and Anthropic input schemas. Free, no signup.

Paste or upload OpenAPI

Privacy: Your OpenAPI file never leaves this browser. Conversion runs locally.

Output

Your result appears here

How to Use

  1. 1Paste OpenAPI JSON/YAML or upload a spec (or load the sample).
  2. 2Select the operations you want as agent tools.
  3. 3Pick Zod, JSON Schema, OpenAI, and/or Anthropic outputs.
  4. 4Generate, copy into your app, or download the ZIP. Validate with MCP Tool Checker if needed.

Example outputs

Zod

export const ListPetsInputSchema = z.object({ limit: z.number().int().optional() })

TypeScript validators with inferred types.

OpenAI tools

{ "type": "function", "function": { "name": "list_pets", "parameters": { ... } } }

Drop into Chat Completions tools arrays.

Anthropic tools

{ "name": "list_pets", "input_schema": { "type": "object", ... } }

Messages API tool definitions with input_schema.

Schema tips for reliable tool calling

  • •Add operationId and clear summaries so tool names and descriptions stay stable.
  • •Prefer enums and required fields over optional free-form strings.
  • •Exclude admin/DELETE routes unless the agent should mutate production data.
  • •Use Zod in TypeScript apps; use OpenAI/Anthropic JSON for hosted LLM APIs.
  • •Need a Cursor MCP process? Use OpenAPI to MCP after you like these schemas.

How this converter works

Parsing and code generation run in the browser. parseOpenApiSpec accepts JSON or YAML, resolves local #/ references, and maps each operation to an McpToolDef with parameters, request body fields, and an included flag. generateToolSchemas then emits up to four files: Zod validators, JSON Schema draft 2020-12, an OpenAI Chat Completions tools array, and an Anthropic Messages tool array. A README lists the included tools.

No model is called, and the spec never leaves your device. The output is deterministic: the same spec and the same selected operations produce the same files.

A real conversion

The built-in Petstore sample parsed to 3 tools with 0 warnings on 2026-11-16. This is the generated Zod for list_pets, then the matching OpenAI tool, with no edits:

export const ListPetsInputSchema = z.object({
  "limit": z.number().int().describe("query parameter: limit").optional(),
});
{
  "type": "function",
  "function": {
    "name": "list_pets",
    "description": "List all pets. Returns a paginated list of pets.",
    "parameters": {
      "type": "object",
      "properties": {
        "limit": { "type": "integer", "description": "query parameter: limit" }
      },
      "additionalProperties": false
    }
  }
}

The limit argument is optional because the spec does not mark it required. The description comes from the operation summary, which is why a clear summary matters for tool calling.

What the output cannot cover

  • Remote $ref files are not fetched. Only local references resolve, so a spec split across files needs to be bundled first.
  • Swagger 2.0 support is best-effort. OpenAPI 3.0 and 3.1 give the cleanest output.
  • oneOf, anyOf, and discriminators can collapse into a permissive schema. Tighten the union by hand when the contract is strict.
  • Auth headers and OAuth tokens are not model-visible arguments. Keep credentials in your client or server, outside the tool input.
  • Multipart and binary bodies do not map cleanly to JSON. Expose a URL parameter or a separate upload step instead.
  • Tool names follow operationId when it exists. Without one, a path edit can rename the tool and break saved prompts.
  • The files define shapes. They do not validate a live response or run the API.

When to use something else

  • To generate a runnable MCP server for Cursor or Claude Desktop, use OpenAPI to MCP.
  • To infer a schema from example JSON instead of a spec, use JSON to Schema.
  • To score the generated tools for agent readiness, use the MCP Tool Checker.

Frequently Asked Questions

What does OpenAPI to Tool Schemas produce?

It turns OpenAPI/Swagger operations into agent-ready input schemas: Zod TypeScript, JSON Schema, OpenAI function tools, and Anthropic tools with input_schema, without generating a full MCP server process.

How is this different from OpenAPI to MCP?

OpenAPI to MCP builds a runnable MCP server package for Cursor/Claude Desktop. This tool emits portable schema files for function calling, validation, and custom agent runtimes. Use both: schemas for apps, MCP for IDE agents.

Which OpenAPI versions are supported?

OpenAPI 3.0/3.1 (JSON or YAML) work best. Swagger 2.0 is best-effort. Local #/ $refs are resolved in-browser; remote $refs are not fetched.

Does my OpenAPI leave the browser?

No. Parsing and codegen run entirely client-side. Instant Tools never uploads your specification for this tool.

Can I use the OpenAI tools JSON with the Responses API?

The openai-tools.json file follows the Chat Completions tools shape ({ type: "function", function: { name, description, parameters } }). Adapt field names if your SDK expects the newer flat function tool format.

Is this converter free?

Yes. No signup, no usage limits, and you own the generated schemas.

Why is a generated tool name different from my operation?

The tool name comes from operationId when it exists. Without one, the parser builds a name from the method and path, so a later path edit can rename the tool. Set a stable operationId in the spec.

Does it handle oneOf, anyOf, or discriminators?

It maps the common cases, but complex compositions can collapse into a permissive schema. Read the generated Zod and tighten the union by hand when the API contract is strict.

Are auth headers turned into tool arguments?

No. Security schemes are not encoded as model-visible arguments. Keep API keys and OAuth tokens in your client or server, and pass them outside the tool input.

Can it handle file uploads or multipart bodies?

Only in a limited way. A multipart body is not a clean JSON schema, and a binary field cannot be described as a normal string. Model the upload as a separate step or expose a URL parameter instead.