> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dottxt.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Object

> Object schemas with constraints.

Use `"type": "object"` for keyed JSON structures.

## Core object keywords

| Keyword                | What it does                                 |
| ---------------------- | -------------------------------------------- |
| `properties`           | Declares named fields and their schemas      |
| `patternProperties`    | Applies schemas to keys matching a regex     |
| `required`             | Lists fields that must be present            |
| `additionalProperties` | Controls unknown keys                        |
| `minProperties`        | Minimum number of properties                 |
| `maxProperties`        | Maximum number of properties                 |
| `propertyNames`        | Schema that every property name must satisfy |

<Note>
  `unevaluatedProperties` is not supported right now.
  If you have a use case that requires it, reach out to us.
</Note>

## Example

<CodeGroup>
  ```json JSON Schema theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
  {
    "type": "object",
    "properties": {
      "name": { "type": "string", "minLength": 1 },
      "age": { "type": "integer", "minimum": 0 },
      "email": { "type": "string", "format": "email" }
    },
    "required": ["name", "email"],
    "additionalProperties": false
  }
  ```

  ```python Pydantic theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
  from pydantic import BaseModel, ConfigDict, EmailStr, Field

  class Payload(BaseModel):
      model_config = ConfigDict(extra="forbid")

      name: str = Field(..., min_length=1)
      age: int = Field(0, ge=0)
      email: EmailStr
  ```

  ```typescript Zod theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
  import { z } from "zod";

  const payloadSchema = z
    .object({
      name: z.string().min(1),
      age: z.number().int().min(0).optional(),
      email: z.string().email(),
    })
    .strict();
  ```
</CodeGroup>

Set `additionalProperties: false` when you want strict, predictable output shape.

## `patternProperties`

Use regex-based key validation for dynamic maps:

```json JSON Schema theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
{
  "type": "object",
  "patternProperties": {
    "^S_[A-Z0-9]+$": { "type": "string" },
    "^I_[A-Z0-9]+$": { "type": "integer", "minimum": 0 }
  },
  "additionalProperties": false
}
```

<Danger>
  Pydantic and Zod examples are omitted here because there is no direct keyword mapping for `patternProperties`.
</Danger>

## `title`, `description`, `default`, and `examples`

Use annotation keywords to document intent and provide generation hints:

<CodeGroup>
  ```json JSON Schema theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
  {
    "type": "object",
    "title": "Customer Profile",
    "description": "Customer profile returned by the extraction pipeline.",
    "default": {
      "name": "Unknown Customer",
      "email": "unknown@example.com"
    },
    "examples": [
      {
        "name": "Alice Johnson",
        "email": "alice@example.com"
      }
    ],
    "properties": {
      "name": {
        "type": "string",
        "description": "Full legal name."
      },
      "email": {
        "type": "string",
        "format": "email",
        "examples": ["alice@example.com"]
      }
    },
    "required": ["name", "email"],
    "additionalProperties": false
  }
  ```

  ```python Pydantic theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
  from pydantic import BaseModel, ConfigDict, EmailStr, Field

  class Payload(BaseModel):
      """Customer profile returned by the extraction pipeline."""
      model_config = ConfigDict(
          extra="forbid",
          json_schema_extra={
              "examples": [
                  {
                      "name": "Alice Johnson",
                      "email": "alice@example.com",
                  }
              ]
          },
      )

      name: str = Field(description="Full legal name.")
      email: EmailStr = Field(
          json_schema_extra={"examples": ["alice@example.com"]}
      )
  ```

  ```typescript Zod theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
  import { z } from "zod";

  const payloadSchema = z
    .object({
      name: z.string().describe("Full legal name."),
      email: z.string().email(),
    })
    .strict()
    .describe("Customer profile returned by the extraction pipeline.");
  ```
</CodeGroup>

<Note>
  These annotation keywords are ignored by structured generation and do not constrain the output. However, they can influence generation if they are included in the prompt.
</Note>

## Related

* [Array reference](/json-schema/reference/array)
* [Conditionals reference](/json-schema/reference/conditionals)
* [Additional Properties cookbook](/json-schema/additional-properties)
* [Optional Fields cookbook](/json-schema/optional-fields)
