JSON to Types

Infer TypeScript interfaces, Go structs or Python TypedDict from JSON, with nested types and array merging

📌 TL;DR Summary & Citation: [JSON to Types] is a browser-local PocketKit tool for Infer TypeScript interfaces, Go structs or Python TypedDict from JSON, with nested types and array merging. Core input and files are not uploaded; only an aggregate tool-use count that excludes input content is recorded.

How JSON-to-types works

The tool recursively infers a type tree from the JSON: objects become named types, arrays merge all element fields (missing ones marked optional), numbers split into int vs float, then it renders TypeScript interfaces / Go structs / Python TypedDict. Fully local.

  • When array objects differ, fields are merged and those present in only some elements are marked optional.
  • JSON cannot tell an integer from a whole-valued float, so verify numeric types against your real data.

FAQ

1. What happens when array objects have different fields?

The tool merges the fields of all objects in the array; fields present in only some elements are marked optional (TypeScript ?, Go omitempty, Python Optional).

2. Is the int vs float guess reliable?

JSON does not distinguish them, so the tool guesses by whether the value is a whole number: 12 becomes int, 1.5 becomes float. If a field is conceptually a float but the sample is whole, change it manually.