JSON to Claude
The result appears here.
Generate
Your document never leaves the browser.
A structured-output schema for Claude, from an example answer — in your browser.
Claude can be held to a JSON Schema, either as the shape of its answer or as the input of a strict tool. Paste an example of what you want back and this page writes a schema that fits Claude’s rules and says when it is near one of Claude’s limits.
Unlike OpenAI’s strict mode, Claude accepts a property that is not required. So gift-wrap, missing from one of the line items, is simply left out of required, and keeps its plain boolean type. note, which the sample shows as null once, is typed ["null", "string"] and stays required.
Every object is closed with additionalProperties: false, so Claude cannot add keys of its own, and the nested objects are defined once under $defs. For this sample the list under the schema is empty, because nothing had to change to fit.
The sample, an order with two line items, pasted as the source
{
"order_id": 1042,
"placed_at": "2026-09-25T10:15:00Z",
"paid": true,
"customer": { "name": "Ada Lovelace", "email": "[email protected]" },
"items": [
{ "sku": "PEN-01", "qty": 2, "price": 3.5, "note": null },
{ "sku": "INK-07", "qty": 1, "price": 12, "note": "Fragile", "gift-wrap": true }
]
}The schema written for it
{
"type": "object",
"properties": {
"order_id": {
"type": "integer"
},
"placed_at": {
"type": "string"
},
"paid": {
"type": "boolean"
},
"customer": {
"$ref": "#/$defs/Customer"
},
"items": {
"type": "array",
"items": {
"$ref": "#/$defs/Item"
}
}
},
"required": [
"order_id",
"placed_at",
"paid",
"customer",
"items"
],
"additionalProperties": false,
"$defs": {
"Customer": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"email": {
"type": "string"
}
},
"required": [
"name",
"email"
],
"additionalProperties": false
},
"Item": {
"type": "object",
"properties": {
"sku": {
"type": "string"
},
"qty": {
"type": "integer"
},
"price": {
"type": "number"
},
"note": {
"type": [
"null",
"string"
]
},
"gift-wrap": {
"type": "boolean"
}
},
"required": [
"sku",
"qty",
"price",
"note"
],
"additionalProperties": false
}
}
}An answer and a score
{ "answer": "yes", "score": 0.9 }With Output Request fragment and Use Strict tool
{
"tools": [
{
"name": "root",
"strict": true,
"input_schema": {
"type": "object",
"properties": {
"answer": {
"type": "string"
},
"score": {
"type": "number"
}
},
"required": [
"answer",
"score"
],
"additionalProperties": false
}
}
]
}Option
Output: Schema, the default, or Request fragment, the part of the Messages API request that carries it.
Option
Use, shown for a fragment: JSON output, the default, which places the schema under output_config.format, or Strict tool, which writes a tools entry with strict set to true and the schema as its input_schema.
Option
Name, shown for a strict tool: the tool’s name, defaulting to your root name in snake_case.
Option
Make all fields required: off by default. Turn it on to require every property and allow null in place of a missing one, as OpenAI’s mode does.
Claude allows at most 24 optional properties in one request, and at most 16 properties that use anyOf or a list of types. It also rejects a schema whose shape refers back to itself. The page counts all three and warns under the schema, and for too many optional properties it suggests the Make all fields required switch.
A root that is a list rather than an object is wrapped as a required property named items. A value the inference could not type becomes a string, and the list under the schema names its path.
A list of records as the root
[
{ "id": 1 },
{ "id": 2 }
]Wrapped as a required property named items
{
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"$ref": "#/$defs/RootItem"
}
}
},
"required": [
"items"
],
"additionalProperties": false,
"$defs": {
"RootItem": {
"type": "object",
"properties": {
"id": {
"type": "integer"
}
},
"required": [
"id"
],
"additionalProperties": false
}
}
}Inference and code generation both run inside this browser tab. The sample is never uploaded, stored on a server or logged, because the page has no server to send it to, and once loaded it carries on working with the connection off.
No. The schema is written in the browser, and you make the request yourself, from your own code with your own API key.
JSON output when the answer itself should be the JSON. A strict tool when Claude should decide to call it, or when you already route answers through tools.
Your sample has more than 24 keys that were missing somewhere. Turn on Make all fields required, or trim the sample to the fields you need.