JSON to TypeScript: Generate Interfaces from JSON

Turn sample JSON into TypeScript, Zod, Go or Python types. Nested objects, arrays, optional fields and unions are handled.

Loading tool…

How to use the JSON to TypeScript

  1. Paste a sample of your JSON data or upload a .json file.
  2. Choose TypeScript, Zod, Go or Python and set the root type name.
  3. Set options such as interface or type, export, readonly and ISO date handling.
  4. Copy the generated code or download it.

About this tool

The converter reads your sample and infers a type for every value: string, number (int or float), boolean, null, arrays and nested objects. Each nested object becomes its own named type (an address key becomes Address), and array items are named from their key in singular form. Names that clash get a number added.

When an array contains several objects, their shapes are merged into one type. A key missing from some objects is optional, a key whose type differs becomes a union, and null makes a field nullable. Output targets: TypeScript interfaces or types, Zod schemas with an inferred type, Go structs with json tags (unions become interface{}), and Python TypedDict classes (Python 3.11+). ISO date strings can optionally be treated as dates (Date, z.coerce.date(), time.Time, datetime).

Types are only as good as the sample. If a field is always a string in your sample but can be a number or null in production, the type will be too narrow. Use a sample that includes edge cases and treat the result as a starting point. For strict API contracts, generate types from an OpenAPI or JSON Schema definition instead. Java and C# output is not offered.

Frequently asked questions

How are optional fields detected?

When you give an array of objects, any key absent from at least one object is marked optional.

What happens with null values?

A null value makes the field nullable (string | null in TypeScript, .nullable() in Zod, a pointer in Go, str | None in Python).

Should I use interface or type?

Both work for object shapes. Interfaces can be extended and merged, while type aliases are more flexible with unions.

Can it output Zod, Go or Python?

Yes. Pick the language at the top. Zod output needs the zod package, and Python output needs Python 3.11 or newer.

Is my JSON uploaded?

No. The code is generated in your browser.

Need a custom tool or website?

IDM Valley builds web apps, calculators, AI chatbots and automation for businesses. Fixed prices, code in your name.

Get a free quote

Have a project in mind?

Tell us what you need: a website, landing page, AI chatbot or automation. You get a clear scope and a fixed price within one working day. Free, no obligation.


  • avshack
  • DivineBamboo
  • goldleaf
  • janapril
  • kaizen
  • kwc
  • modv
  • pixelrush
  • revital
  • riderzplanet
  • sandsfashions
  • avshack
  • DivineBamboo
  • goldleaf
  • janapril
  • kaizen
  • kwc
  • modv
  • pixelrush
  • revital
  • riderzplanet
  • sandsfashions