# AI tool schema generator

URL: https://byshahid.com/tools/ai-tool-schema-generator/
Author: Muhammad Shahid (https://byshahid.com/)
Free tool · runs in your browser

Paste an example of the JSON your AI tool should receive, and get a JSON Schema or a complete Claude tool definition for function calling.

**Quick answer:** AI function calling and structured outputs need a JSON Schema that describes the expected arguments. This tool infers one from a sample: types for every field, nested objects and arrays, every field marked required and additionalProperties: false, which is what strict tool use expects. You can output plain JSON Schema or a Claude tool with name, description and input_schema.

## How to use it

1. **Paste sample JSON.** One realistic example of the arguments, for example a booking with a name, date and number of people.
2. **Name the tool.** Give it a short name and a description of when the model should use it.
3. **Copy the result.** Use it as a tool definition, then add descriptions and enums for the fields that need them.

## Example

An example booking turned into a strict JSON Schema:

Input:

```
{ "email": "sara@example.com", "date": "2026-11-12", "people": 2 }
```

Output:

```
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "email": { "type": "string", "format": "email" },
    "date": { "type": "string", "format": "date" },
    "people": { "type": "integer" }
  },
  "required": ["email", "date", "people"],
  "additionalProperties": false
}
```

## Common errors and how to fix them

- **Unexpected token … is not valid JSON**: The sample is not valid JSON: check for single quotes, trailing commas and unquoted keys. The [JSON formatter](https://byshahid.com/tools/json-formatter/) shows exactly where.
- **A tool input must be a JSON object**: Tool inputs must be objects. Wrap a list or a single value in an object, such as { "items": [...] }.
- **The model leaves out optional fields or invents values**: Every field in the sample becomes required. Remove fields that are optional from required, or allow null for them.
- **Invalid tool name**: Tool names may only use letters, numbers, _ and -, up to 64 characters. This tool replaces other characters with _.

## Frequently asked questions

### What is function calling?

A way for an AI model to ask your code to run an action, such as looking up an order, by returning structured arguments that match a schema you define.

### Why mark every field as required?

Strict tool use expects a schema where every property is listed as required and no extra properties are allowed, so the model's arguments always match.

### Should I edit the generated schema?

Yes. Add a description to each field, enums for fixed choices and formats such as date, so the model knows exactly what to send.

### How does the generator handle arrays?

It uses the first item of each array to infer the item schema; make sure your sample has at least one item.

### Is my JSON uploaded?

No. The schema is generated in your browser.

### What is the difference between JSON Schema and a tool definition?

JSON Schema describes data. A tool definition wraps a schema with a name and a description, so the model knows when and how to call the tool.

### How should I write a tool description?

Say what the tool does, when to use it and when not to. The model reads this text to decide whether to call the tool.

### How do I make a field optional in a strict schema?

Strict tool use expects every field to be required. To allow "no value", make the field's type a union with null, such as ["string", "null"].

### Can a tool take nested objects and arrays?

Yes, and the generator infers nested schemas from your sample. Keep nesting shallow where you can; simple arguments are easier for models to fill in correctly.

### Should I still validate tool arguments in my code?

Yes. Always validate before running anything, especially actions with side effects, even when the schema is strict.

## Related

- [JSON formatter and validator](https://byshahid.com/tools/json-formatter/)
- [How to make AI tool calls safe](https://byshahid.com/engineering/ai-agents-langgraph-n8n-production/)
- [Hire an AI agent developer](https://byshahid.com/hire/ai-agent-developer/)

## Sources

- [Anthropic Docs: Tool use](https://platform.claude.com/docs/en/agents-and-tools/tool-use/overview)
- [JSON Schema](https://json-schema.org/)
