Free JSON to TypeScript Converter
Convert a JSON payload into TypeScript interfaces · nested objects and arrays included · ready to paste into your codebase.
100% client-side · nothing you enter is ever sent to a server or stored.
Preview · sign in with a free account to run it
Nested objects become named interfaces · identical shapes are deduplicated · array elements are merged, with keys missing from some elements marked optional.
How to use it
- Paste a JSON sample, ideally a real API response with every field filled in.
- Set the root interface name, for example User.
- Copy the interfaces. Nested objects become their own interfaces, and array item names are singularised.
Example
Input
{"id":42,"name":"Ada","tags":["admin","beta"],
"address":{"city":"London","zip":null},
"orders":[{"id":1,"total":9.99},{"id":2,"total":24,"coupon":"BF26"}]}Result
export interface User {
id: number;
name: string;
tags: string[];
address: Address;
orders: Order[];
}
export interface Order {
id: number;
total: number;
coupon?: string;
}
export interface Address {
city: string;
zip: null;
}How types are inferred
- Optional fields (?)
- A key that appears in some array items but not others becomes optional, like coupon above.
- null
- A field that is null in the sample is typed null. Replace it with the real type, such as string | null.
- Arrays
- Objects in an array are merged into one interface. Mixed primitives become a union, such as (string | number)[].
- Names
- orders becomes Order and address becomes Address. Rename anything that reads oddly.
Go deeper
Page updated
Frequently asked questions
How are arrays with mixed types handled?
Element types are unioned · an array of strings and numbers becomes (string | number)[]. Objects across array elements are merged, and keys missing from some elements are marked optional.
Why type API responses at all?
Untyped responses are where runtime bugs hide: a renamed field fails silently until production. Generated interfaces give the compiler a chance to catch drift · pair them with runtime validation (like zod) for full safety.
Are these types checked at runtime?
No. TypeScript types disappear when the code is compiled. To check untrusted input at runtime, use a validator such as Zod or Joi.
Want the full picture?
This tool covers one narrow check. A full SimplyScan runs 60 checks across 14 categories · exposed keys, RLS, XSS, auth, and speed · in 30 seconds.
Run a full security scanRelated tools
CSV ↔ JSON Converter
Convert between CSV and JSON in either direction · with proper handling of quoted fields, commas inside values, and headers.
Base64 Encoder / Decoder
Encode text to Base64 or decode it back · with full UTF-8 support. Handy for inspecting tokens, data URIs, and encoded config.
URL Encoder / Decoder
Encode or decode percent-encoded URLs · with separate modes for full URLs and individual query components.