Skip to content
Discussion options

You must be logged in to vote

Hi @flekschas! I'm Dosu and I’m helping the zod team.

Yes, this is fully supported in Zod v4. Descriptions you add with .describe() (or with .meta({ description: ... })) are included in the output of toJSONSchema(). Your example will work as expected, and the descriptions will appear in the generated JSON Schema under each property.

For more complex metadata (like title, examples, etc.), use .meta(), but for simple descriptions, .describe() is fine. Here’s an example from the docs:

const mySchema = z.object({
  firstName: z.string().describe("Your first name"),
  lastName: z.string().meta({ title: "last_name" }),
  age: z.number().meta({ examples: [12, 99] }),
});

z.toJSONSchema(mySchema);

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@flekschas
Comment options

Answer selected by flekschas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant