JSON/YAML to Type Definitions

Paste a JSON payload or a YAML snippet. The same inferred shape is emitted as TypeScript interfaces, Go structs, Rust serde structs, Python Pydantic models, and Zod schemas.

JSON / YAML → type definitions

One paste. TypeScript, Go, Rust, Pydantic, and Zod — inferred in this browser.

Inferred from this sample only. Empty arrays, mixed types, and a lone 1 vs 1.0 still need a human.

Why one language is not enough

Most converters pick a camp: JSON → TypeScript, or JSON → Go. A backend change often lands in more than one repo. You want the TypeScript client, the Go handler, the Pydantic ingest model, and a Zod schema from the same example payload, not four slightly different guesses.

This page infers one shape, then prints it five ways. Nested objects become named types. Fields missing on some array elements become optional. null becomes a nullable type, not a silent any.

What to review before you commit

  • Numbers: integers vs floats. A sample 1 is not proof the field is int.
  • Empty arrays: the element type is unknown until you have an example.
  • YAML is a common subset (maps, lists, scalars). Anchors and merge keys are not fully supported — convert those with your usual YAML library first, or paste JSON.
  • Generated names can collide with keywords (type, error). Rename those by hand.

Go-only extras (bson / mapstructure tags, pointer-null policy) still live on the JSON to Go Struct Converter. Use this page when you need more than Go.