JSON to TypeScript

Paste JSON and instantly generate clean TypeScript interfaces or type aliases — nested objects, arrays, and optional fields handled automatically.

🔒 Runs entirely in your browser — your JSON never leaves your device
0 lines
Your types will appear here.
Types created
0
Fields
0
Lines of code
0

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 User or Product to 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.

1

Paste your JSON

Drop a sample of your data — an API response, a config file, or any JSON object.

2

Choose how it looks

Name the main type, pick interface or type alias, and decide which fields are optional.

3

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?
An interface describes the shape of an object — the names of its fields and what kind of value each one holds, like 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?
Yes. Nested objects become their own named types, and arrays are turned into typed lists like 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?
Turn on “Mark null & missing fields optional” and any field that is 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?
Both describe the same shape. An 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?
When a value is an empty array or 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.
Is my JSON uploaded anywhere?
No. Everything runs inside your browser — your data never leaves your device and nothing is sent to a server.