Skip to main content
DevToys
Converters

JSON to type definitions

Generate TypeScript, Go, and Python types from a JSON sample

Output language

Nested objects are named after their key; array element names are singularised.

JSON sample
Output
How to use / Notes

How to use

  1. Paste a JSON sample—an API response, for example—into the left pane.
  2. Choose the output language: TypeScript, Go, or Python.
  3. Rename the root type if you like; nested objects are named after their key.
  4. Copy the generated definitions into your project.

Notes

  • Types are inferred from one sample, so fields and values the sample never shows cannot be represented.
  • Array elements are merged, so keys missing from some elements become optional—include several shapes for a better result.
  • JSON does not distinguish integers from floats; a value without a decimal point is inferred as an integer type.
  • A field that is only ever null carries no type, so it becomes null in TypeScript and any/Any in Go and Python.
  • Dates and UUIDs are inferred as strings; swap in a richer type after generating if you need one.