JSON to Gemini
The result appears here.
Generate
Your document never leaves the browser.
A response schema for Gemini, from an example answer — in your browser.
Gemini returns JSON in a shape you choose when the request carries a response schema. Paste an example of the answer you want and this page writes that schema, or the whole generation config around it, ready to drop into your call.
Gemini takes a JSON Schema with fewer changes than the other two providers. A key missing from some records, such as gift-wrap, is left out of required and keeps its own type; a key that is sometimes null, such as note, is typed ["null", "string"]. Nested objects are defined once under $defs.
A root that is an array needs no wrapping for Gemini, so a list of records stays a list at the top level. And when a document has more distinct shapes than the page can name, the open record it falls back to is a plain object type here, where OpenAI and Claude need a list of key and value pairs.
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": "ada@example.com" },
"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
{
"generationConfig": {
"responseMimeType": "application/json",
"responseJsonSchema": {
"type": "object",
"properties": {
"answer": {
"type": "string"
},
"score": {
"type": "number"
}
},
"required": [
"answer",
"score"
],
"additionalProperties": false
}
}
}Option
Output: Schema, the default, gives the schema on its own. Request fragment writes the part of the request that carries it, with the MIME type set to application/json.
Option
API, shown for a fragment: generateContent, the default, which puts the schema under generationConfig as responseJsonSchema, or interactions, which puts it under response_format for the Interactions API.
The schema says what shape the answer takes, not what it means. Describe each field in your prompt, or add a description to the schema yourself, and the model’s values will be closer to what you want.
Keys are written exactly as your sample spells them, hyphens and all, because the model’s answer has to match them. A value the inference could not type is sent as a string, and the list under the schema says where. Unlike the Claude and OpenAI pages, no limits are checked here, so test a very large schema against the API before depending on it.
A hyphenated key and an empty list
{ "gift-wrap": true, "tags": [] }The key kept as written, and the unknown items sent as strings
{
"type": "object",
"properties": {
"gift-wrap": {
"type": "boolean"
},
"tags": {
"type": "array",
"items": {
"type": "string"
}
}
},
"required": [
"gift-wrap",
"tags"
],
"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. It only writes the schema, in this browser tab. The request is made by your own code, with your own key.
The page writes responseJsonSchema, which takes standard JSON Schema such as this one. responseSchema takes Google’s own OpenAPI-style subset.
Because nothing in your sample needed changing to fit Gemini. It lists changes only when one was made.