JSON to TypeScript, Zod, Go, Python Converter Online

Generate TypeScript interfaces, Zod schemas, JSON Schema 2020-12, Go structs, Python dataclasses or Pydantic models from one or more JSON samples.

Free tool: 20 requests per minute.

Result

Press “Run” to see the result.

Paste a JSON sample in json (or several in samples) and choose lang: typescript, zod, json-schema, go, python (dataclasses), pydantic (v2), a comma-separated list or all. Samples are merged field by field: a field missing from some objects becomes optional, mixed kinds become unions, null makes a field nullable, integers and decimals merge into a number, and a top-level array of objects is read as a list of records of one type.

Nested objects get their own named types from the key (array items are singularised: items → Item, addresses → Address), identical shapes share one type, and strings are tagged with a format when every sample matches: RFC 3339 date-time (→ time.Time, datetime, z.string().datetime()), date, time, UUID, e-mail, URL. With enums=true short string fields with repeated values become literal unions / enums. Keys that are not valid identifiers are quoted (TypeScript, Zod), tagged (Go json:"…") or aliased (Pydantic Field(alias=…)).

The generator is our own (no quicktype): up to 100 samples, 200,000 values and 64 levels of nesting. code holds the first language, output every language requested. Python output uses X | None syntax (Python 3.10+).

Use this in your code

curl -X POST "https://apibox.io.vn/v1/json-to-types" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"json":{"id":1,"name":"An","created_at":"2026-11-10T08:30:00Z","tags":["vip"],"address":{"city":"Hà Nội","zip":null}},"lang":"typescript","name":"Customer"}'

API documentation → Get a free API key

FAQ

How do I mark fields as optional?

Send several samples in "samples": fields absent from some of them become optional (?, .optional(), pointer + omitempty, = None).

Which Zod version is targeted?

Zod 3 syntax (z.string().datetime(), .email(), .uuid()), which also works in Zod 4.

Are dates detected?

Yes, strings that are RFC 3339 date-times or YYYY-MM-DD dates in every sample; detect_dates=false keeps them as plain strings.