JSON to TypeScript
Paste JSON and instantly generate clean TypeScript interfaces or type aliases — nested objects, arrays, and optional fields handled automatically.
Your types will appear here. About the JSON to TypeScript Converter
Writing type definitions by hand from a sample API response is slow and easy to get wrong. This tool reads your JSON and figures out the structure for you: it recognises text, numbers, true/false values, and empty values, turns nested objects into their own named types, and works out the element type of every list — even when a list mixes different kinds of values. The result is clean, readable TypeScript you can paste straight into your project.
- Paste a real response with a few array items so optional fields are detected accurately.
- Give the main type a meaningful name like
UserorProductto keep nested type names tidy. - Switch to “Type alias” if you prefer unions, or keep “Interface” for objects you may extend later.
How it works
Three steps. No sign-up, no upload, no wait.
Paste your JSON
Drop a sample of your data — an API response, a config file, or any JSON object.
Choose how it looks
Name the main type, pick interface or type alias, and decide which fields are optional.
Copy the code
Grab ready-to-use TypeScript types, generated live as you type.
Private by design.Everything happens right here in your browser. Your files are never uploaded — we never see them.
Frequently Asked Questions
What is a TypeScript interface? ▼
string, number, or boolean. It lets your editor catch typos and mistakes before you ever run the code. This tool reads your JSON and writes the matching interface for you.Does it handle nested objects and arrays? ▼
string[] or Item[]. If an array mixes different kinds of values, the tool combines them into a single type (for example (string | number)[]) so nothing is lost.How does it decide which fields are optional? ▼
null, or that only appears in some items of a list, gets a ? after its name. That marks it as optional, matching how the data really behaves.What is the difference between interface and type alias? ▼
interface is the most common choice for objects and can be extended later, while a type alias is more flexible for unions and combinations. Pick whichever fits your project — the tool generates both styles.Why do some types come out as any? ▼
null with nothing to learn from, there isn't enough information to guess a precise type, so the tool falls back to any[] or null. Add one real example to the data and the type sharpens automatically.