JSON to TypeScript Interfaces
Example
Input:
{"name": "Ali", "age": 30, "skills": ["ts", "go"]}Output:
interface Root {
name: string;
age: number;
skills: string[];
}About this converter
Type generation from sample JSON is inference, not mind-reading: the converter walks the value, maps JSON types to TypeScript types (numbers unify int/float into number, since JSON itself does not distinguish), extracts nested objects as their own interfaces named after their key, and — when the input is an array of objects — merges the objects, marking any key that does not appear in every item as optional. Fields that are null in the sample type as null; if your real data sometimes has a string there, widen the type. Treat the output as a strong first draft of your types: review it the way you would a colleague's pull request.
Frequently Asked Questions
Why did my integer become just "number"?
JSON has one number type; TypeScript interfaces follow it. The int/float distinction only appears in the Go output (int64/float64).
What does the ? on a field mean?
The field was absent in at least one object of the input array, so it is optional in the merged interface.