JSON type generator converts a JSON sample into TypeScript, Rust, Kotlin, Python, or JSON Schema type definitions automatically. Paste JSON on the left, select an output mode, and the generated code appears on the right in real time. It removes the tedious work of manually declaring types for API responses and data models.
Output mode examples
Given this JSON input:
{
"user": {
"id": 123,
"name": "Alice",
"roles": ["admin", "viewer"]
}
}
TypeScript (interface) produces:
export type Root = {
user: User;
};
export type User = {
id: number;
name: string;
roles: string[];
};
Rust produces structs with #[derive(Serialize, Deserialize)] annotations that depend on serde. Python produces Pydantic v2 BaseModel classes. Kotlin (Jackson) produces data classes with @JsonProperty annotations.
All 8 output modes
- TypeScript (interface): separate
interfacedeclarations per object — good for large projects - TypeScript (single type alias): inline
typewith nested types inlined — quick to use - Rust: serde-annotated structs
- Kotlin (Jackson):
@JsonPropertydata classes - Kotlin (kotlinx.serialization):
@Serializabledata classes - Python (Pydantic): Pydantic v2
BaseModel - JSON Schema: standard schema format for API documentation
- Shape: the tool's internal type analysis intermediate representation — useful for debugging inference
How type inference works and where it falls short
The tool infers types statically from the sample you provide:
- Numbers are not distinguished between integer and float (TypeScript gets
number, Rust getsi64/f64based on value shape) - A
nullvalue makes the field optional - Mixed-type arrays produce a union type
- An empty array produces
unknown[]
These inferences are only as good as the sample. If your API sometimes returns null for a field but your sample always has a value, the generated type will miss the optionality. Always review the output against the full range of real data your API returns.
Advanced options
Property name format: converts JSON snake_case keys to the target language's convention — camelCase, PascalCase, snake_case, SCREAMING_SNAKE_CASE, or kebab-case.
Type name: sets the root type name. Default is Root — rename it to something meaningful like UserResponse before pasting into your codebase.
Expand path: uses JSON Pointer syntax (e.g. /items/-/data) to promote a deeply nested path to the top level. The - is an array wildcard, useful for paginated API responses where the data lives inside items[].data.
Collect extra properties: adds an index signature ([key: string]: unknown in TypeScript) to allow fields beyond what the sample contains.