Free JSON to TypeScript Converter

Paste JSON to get ready-to-use TypeScript interfaces — optional fields and union types inferred from your data.

JSON input
TypeScript output

How to use / FAQ

Paste any JSON — an API response, a config file, a webhook payload — and complete TypeScript interfaces appear as you type. Nested objects become their own named interfaces, and the generator studies every item in an array to work out which fields are optional and which types vary. Pick interface or type style, rename the root, and copy the result.

How does it know a field is optional?

By comparing the items in an array. If a key appears in some objects but not others — like a note field on only some orders — it's emitted with a question mark (note?: string). Fields present in every sampled item stay required.

What happens when a field has different types in different places?

It becomes a union: a value that's sometimes a string and sometimes a number is typed string | number, and a field that's sometimes null gets | null appended. Objects with different shapes merge into a single interface with the differing keys marked optional.

Why did an empty array become unknown[]?

An empty array carries no information about what it will hold, and guessing would produce wrong types silently. unknown[] is the honest answer — replace it by hand, or paste a sample where the array has at least one item.

Are the generated types guaranteed to be correct?

They're guaranteed to be valid TypeScript, and correct for the sample you pasted. But JSON is just one snapshot: a field that happened to be present everywhere in your sample could still be optional in the real API. Treat the output as an excellent first draft to review, especially the required/optional decisions. If the sample itself won't parse, run it through the JSON formatter first to find the error.

Is my JSON uploaded anywhere?

No. Inference and generation run entirely in your browser — safe for API responses containing tokens, emails, or customer data.