# Strict JSON schema rules for OpenAI and Claude

> Eight rules that keep a JSON schema from a 400 on OpenAI or Claude structured outputs, plus two jq checks.

Source: https://fullbytedeveloper.com/blog/schema-rules
Published here: 2026-11-17, updated 2026-11-19

OpenAI strict mode and Claude structured outputs reject different JSON schema features, so a schema that works on one can get a 400 on the other [1][2]. These eight rules cover both, and two jq commands check a schema before you send it.

## Apply the eight rules

1. **Both**: `"additionalProperties": false` on every object, nested ones too.

2. **OpenAI**: use `json_schema` with `strict: true`. JSON mode (`json_object`) gives valid JSON, not your schema.

3. **OpenAI**: list every field in `required`. Optional field = `{"type": ["string", "null"]}`.

4. **OpenAI**: up to 5000 object properties, 10 levels of nesting.

5. **Claude raw API**: no minimum, maximum, multipleOf, minLength, maxLength, recursive schemas or external $ref. You get a 400. SDK helpers strip these and check them in your code. OpenAI strict does accept minimum, maximum, multipleOf and pattern.

6. **Key order**: OpenAI keeps schema order. Claude puts required keys first, then optional ones. Read fields by name.

7. **Both**: check for a refusal or a max tokens cutoff before you parse. The output may not match the schema.

8. **Claude**: the first call with a new schema is slower while the grammar compiles; it is cached for 24 h from last use.

Claude also limits one request to 24 optional parameters and 16 parameters with union types, counted across all strict schemas [2]. A nullable field like the one in rule 3 counts as a union type.

## Check your schema with jq

Run both on your `schema.json`:

```bash
jq '[.. | objects | select(.type=="object") | .additionalProperties] | all(. == false)' schema.json
```

```bash
jq -c '[.. | objects | keys[] | select(IN("minimum","maximum","multipleOf","minLength","maxLength"))]' schema.json
```

A schema with an open object, a `minLength` and a `minimum` prints `false` and `["minLength","minimum"]`. After the fix, you should see `true` and `[]`.

Send this to the friend whose JSON schema works on OpenAI and gets a 400 on Claude.

## Sources

1. [OpenAI docs: structured outputs](https://developers.openai.com/api/docs/guides/structured-outputs)
2. [Claude docs: structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs)
