Search and jump to any tool. Type to filter; use arrow keys to move and Enter to select.
The JSON to TypeScript converter reads a sample JSON document and writes matching interfaces.
The JSON to TypeScript converter reads a sample JSON document and writes matching interfaces. Nested objects get their own named interfaces, arrays are typed from their contents, and keys missing from some array items are marked optional. It gives you a quick starting point for typing an API response instead of writing every field by hand.
{"id":1,"name":"Ada","tags":["a"],"address":{"city":"London","zip":null},"posts":[{"title":"x","likes":3},{"title":"y"}]}export interface Root {
id: number
name: string
tags: string[]
address: Address
posts: Post[]
}
export interface Post {
title: string
likes?: number
}
export interface Address {
city: string
zip: null
}Good to know. All JSON numbers become number and date-looking text stays string. Generated types describe only the sample you supplied, so review them against the API's documentation.
Converted to PascalCase automatically.