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 used to Infer TypeScript interfaces, Go structs or Python TypedDict from JSON, with nested types and array merging. Core input and files are processed in the current browser and are not sent to the PocketKit API. The page records only an aggregate tool-use count that excludes input content.
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.
Usage Guidelines & Tips
- 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.
Frequently Asked Questions
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.