json

FormatValidateConvert

JSON to Gemini

JSON
Language
Structured output

Result· read-only

—Gemini

The result appears here.

Generate

JSON to a Gemini response schema.

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.

2

APIs: generateContent and Interactions

gift-wrap

a key kept as the sample spells it, hyphen and all

0

bytes leave your machine

Close to plain JSON Schema

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.

1

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 }
  ]
}
2

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
    }
  }
}

Schema or request fragment

1

An answer and a score

{ "answer": "yes", "score": 0.9 }
2

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

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

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.

Before you send it

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.

1

A hyphenated key and an empty list

{ "gift-wrap": true, "tags": [] }
2

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
}
  • Gemini changed the unknown value at $.tags[] to a string.

Your sample stays here

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.

Read next:

FAQ

Frequently asked questions

Didn’t find your answer?Write to us on the contact page →
Does this page call Gemini?

No. It only writes the schema, in this browser tab. The request is made by your own code, with your own key.

Should I use responseSchema or responseJsonSchema?

The page writes responseJsonSchema, which takes standard JSON Schema such as this one. responseSchema takes Google’s own OpenAPI-style subset.

Why is the list under the schema empty?

Because nothing in your sample needed changing to fit Gemini. It lists changes only when one was made.

Keyboard shortcuts

Send feedback

Questions, bug reports and feature requests are all welcome. A bug report is easiest to act on with the shape of the document that caused it — never send anything confidential.

Email us

Contact page, in a new tab, so this page stays as it is.

Settings

Indent

The result is written with it — YAML and XML at 2 spaces when it is Tab.

Code text size
14 px

Both panes.

Wrap long lines

Load from a URL

Your browser fetches it directly — the request goes to that site, never to us.