Toolstia / JSON to TypeScript, Go, Python and C#
Turn JSON into type definitions
Writing types for an API response by hand is slow and easy to get wrong. Paste a sample response and get matching definitions in the language you use.
Nested objects become their own types, lists of objects are merged into one type, and fields that are missing from some items are marked optional.
Types are guessed from your sample. A field missing from some array items is marked optional. Check the result against your real data.
How it works
- Paste a sample of your JSON.
- Choose TypeScript, Go, Python or C#, and name the top type.
- Copy the generated code.
What you get
TypeScript produces interfaces, Go produces structs with json tags, Python produces dataclasses with snake_case names, and C# produces classes with properties and List collections.
Optional fields
When you give a list of objects, the tool compares all items. A field absent from some becomes optional: a question mark in TypeScript, a pointer in Go, a None default in Python and a nullable type in C#.
Naming
Type names come from the key they belong to, made singular for lists and kept unique. Check them and rename to suit your code.
Only as good as the sample
A sample cannot show every value. A field that is null in your sample has no known type. Treat the output as a head start and compare it with the API documentation.
Questions
Can it handle an array at the top level?
Yes. The item type is generated and the root is a list of it.
Does it generate validation code?
No, only type definitions.
Is anything uploaded?
No. Your JSON stays in your browser and is never sent anywhere.