>_
Py

JSON to Pydantic / Go / Rust

Generate Pydantic models, Go structs with json tags, or Rust serde structs from sample JSON. Detects integers vs floats, optional and nullable fields, and renames keys that aren’t valid identifiers.

Runs locally — your input never leaves this page.

Output
 

How to use

  1. Paste a JSON sample, such as an API response or the structured output you expect from an LLM.
  2. Choose the target: Pydantic (Python), Go or Rust, and set the root type name.
  3. Nested objects become separate types. Missing or null fields become Optional / pointers / Option<T>, and keys like class or user-id are renamed with an alias.

FAQ

Does the Pydantic output work with LLM structured outputs?

Yes. The OpenAI Python SDK, Instructor and many agent frameworks accept a Pydantic BaseModel as the output schema. Add Field(description=...) to guide the model further.

How are numbers typed?

If every value seen at a position is a whole number, it becomes int / int64 / i64; otherwise float / float64 / f64. Use a sample with realistic values for best results.

Report a bug or suggest a feature →