📝 LLM & AI

JSON Schema: Describing Data Structures

P
Author
PyLand Team
📅
Published
30.06.2026
⏱️
Reading time
1 min
👁️
Views
318
🌿
Level
Medium

JSON Schema is a standard for describing the structure of JSON. In the Claude API it is used to define tools (tool use) — it tells Claude exactly which parameters to pass.

Basic Structure

{
  "type": "object",
  "properties": {
    "city": {
      "type": "string",
      "description": "City name"
    },
    "units": {
      "type": "string",
      "enum": ["celsius", "fahrenheit"],
      "description": "Measurement units"
    }
  },
  "required": ["city"]
}

Data Types

# string
{"type": "string", "description": "Text"}

# number (int or float)
{"type": "number", "description": "Number"}

# integer (whole numbers only)
{"type": "integer", "description": "Integer"}

# boolean
{"type": "boolean", "description": "true or false"}

# array
{
    "type": "array",
    "items": {"type": "string"},
    "description": "List of strings"
}

# object (nested)
{
    "type": "object",
    "properties": {
        "x": {"type": "number"},
        "y": {"type": "number"}
    },
    "required": ["x", "y"]
}

Claude API Tool Definition

TOOLS = [
    {
        "name": "search_web",
        "description": "Searches the web. Use it for current information.",
        "input_schema": {
            "type": "object",
            "properties": {
                "query": {
                    "type": "string",
                    "description": "Search query"
                },
                "max_results": {
                    "type": "integer",
                    "description": "Maximum number of results (1-10)",
                    "default": 3
                }
            },
            "required": ["query"]
        }
    },
    {
        "name": "read_file",
        "description": "Reads the contents of a local file",
        "input_schema": {
            "type": "object",
            "properties": {
                "path": {
                    "type": "string",
                    "description": "File path (absolute or starting with ~)"
                }
            },
            "required": ["path"]
        }
    }
]

description Is the Most Important Field

Claude selects tools based on description. The more precise the description, the better the agent picks the right tool:

# Bad
{"name": "weather", "description": "Weather"}

# Good
{"name": "get_weather", "description": "Gets current weather and a city forecast. Use it for questions about weather, temperature, or precipitation."}

Your reaction to the article

💬 Comments (0)

🔐 Sign in to leave a comment
🚪 Login
💭

No comments yet

Be the first to share your opinion about this article!

🔗 Similar

Similar articles

Continue learning with these materials

📝

AI Agents: ReAct Loop and Autonomous Actions

A chatbot answers questions. An agent takes action: it calls tools, retrieves real data, and...

📅 30.06.2026 👁️ 334
📝

Pydantic v2: Data Validation in Python

Pydantic validates and converts data through type annotations. It is commonly used in APIs and...

📅 30.06.2026 👁️ 327
📝

asyncio in Python: Asynchronous Programming

asyncio is Python's standard library for asynchronous code. It lets you execute multiple tasks "simultaneously"...

📅 30.06.2026 👁️ 317
🎓 Continue learning

Courses that cover this material

Visit the course to apply this material in practice.

Neural Networks in Code: 5 AI Projects in Python with Claude Open course curriculum