JSON to TypeScript
Turn any JSON into TypeScript interfaces. Nested types named, optional keys detected.
Runs in your browser. Nothing is uploaded.
Input
Waiting for JSON
TypeScript
TypeScript types appear here.What this does
Paste an API response or any JSON and get TypeScript interfaces for it. Nested objects become their own named types; arrays of objects are merged into one type.
Optional fields
If a key is missing from some items in an array, it is marked optional with ?. Turn on All optional when the API can leave out anything. A value that is sometimes null gets | null.
Names
Types are named after their keys: users becomes User, address becomes Address. Two objects with the same shape share one type. Change the root name in the box above the output.
More json tools
All- JSON to Go StructGenerate Go structs with json tags from any JSON. Nested structs named, pointers for nullable values.
- JSON to Kotlin Data ClassGenerate Kotlin data classes from JSON, for kotlinx.serialization, Gson, or plain Kotlin.
- JSON to Java ClassGenerate Java records or POJO classes with Jackson annotations from any JSON.
- JSON to Python DataclassGenerate Python dataclasses, Pydantic models, or TypedDicts with type hints from any JSON.
- JSON to C# ClassGenerate C# classes for System.Text.Json or Newtonsoft from any JSON. Nullable types detected.
- JSON to Dart ClassGenerate null-safe Dart classes with fromJson and toJson from any JSON. Made for Flutter.
- JSON to Swift CodableGenerate Swift Codable structs with CodingKeys from any JSON.
- JSON to Rust StructGenerate Rust structs with serde derives and Option fields from any JSON.