JSON to JSON Schema
Infer a JSON Schema 2020-12 from one JSON example or several, merged — required keys, nullable values, optional enums — then validate it or make it strict.
What it does
Paste a JSON example, or a list of them, and get the JSON Schema that describes it. With several examples the schema is the one all of them fit: every key any example has, every type any value takes, and the keys that every example has marked as required. Everything runs in your browser: nothing you paste is sent anywhere.
From the result you can go straight on:
- Send to validator opens the JSON Schema Validator with the schema and your first example.
- Check compatibility opens the JSON Schema compatibility checker, which shows what each provider's documentation says about the schema.
- Make strict for Anthropic opens the checker with the schema already rewritten the way Anthropic's SDKs rewrite one for strict structured outputs, with every change listed.
How it infers
Every rule is a reading of the examples and nothing more:
- Required. A key is required when every example that has the object has the key. Turn the option off and nothing is required.
- Nullable. A value that is
nullin one example and a string in another is written"type": ["string", "null"]. - Integer or number. A whole number is an
integer. A value that is whole in one example and a fraction in another is anumber. - Enums, if you ask. A string that takes at most ten values, with at least one repeated, becomes an
enum. A string that is different in every example is a value, not a choice, and stays astring. - Mixed kinds. Scalars of different kinds become a type list. When one of them is an object or a list, each kind is a branch of an
anyOf. - Closed objects, if you ask.
additionalProperties: falseon every object, which strict structured outputs require.
The schema is JSON Schema 2020-12, the dialect Salyro validates an Output Contract with. $schema is added only if you ask, because some providers do not list it among the keywords they accept.
What it does not know
- The rule behind a value. An example is one value. The tool never infers a
format, apattern, a length or a bound:"2026-01-01"is a string, not a date. - What an empty list holds. A list that is empty in every example has no
items, and the note says so rather than guessing. - Whether
1was meant to be1.0. JSON writes both the same way, so an example cannot show that a whole number was meant to be a fraction. - A value that is only ever
null. It is typednull, with a note to widen it. - What a provider accepts. That is the compatibility checker's job; this tool writes standard JSON Schema.
FAQ
How do I give it several examples?
Wrap them in a JSON list, [ {...}, {...} ], and choose A list of examples. Each item of the list is one example.
Why is a key I always send not required?
Because at least one example does not have it. Add the key to that example, or edit required by hand.
Is every example valid against the schema it produces?
Yes. The tests hold every inferred schema to the examples it came from, with every combination of options, using the same validator and settings Salyro uses for an Output Contract.
Sources
The schema follows the JSON Schema 2020-12 specification. The strict rewrite is the compatibility checker's, which quotes Anthropic's structured outputs page. No other provider data is used: the tool works only on what you paste.
Where the numbers come from
- Facts about models and providers that are not in that catalogue carry their own source and the date they were checked, and are shown as unknown where no reliable source exists.
