JSON to TypeScript Converter

Generate TypeScript interfaces from a JSON sample.

Runs in your browser Free · no accountFile upload supported

JSON

TypeScript

This conversion happens locally in your browser. Your files are never uploaded.

About the JSON to TypeScript converter

Paste a JSON response and get TypeScript declarations that describe it. Nested objects become their own named interfaces, arrays are typed by their contents, and mixed arrays produce a union.

It is the fastest way to get types for an API that does not publish a schema — grab one real response and start from there.

How types are inferred

Each distinct object shape becomes an interface named after the property that holds it, converted to PascalCase. An array property called `users` produces an interface called `User`.

Arrays are typed from their elements. If every element has the same shape you get `User[]`; if they differ you get a union of the shapes rather than a lossy `any[]`.

A property whose only observed value is `null` is typed `null` and marked optional, since a single sample cannot tell you what it looks like when populated.

Working from one sample

Generated types describe the sample you pasted, not the API contract. Fields that happen to be absent from your example will be absent from the types, and a field that is sometimes null will look non-nullable.

Paste the richest response you have, then review optional fields by hand. Treat the output as a very fast first draft rather than a specification.

Frequently asked questions

Why is my array typed as unknown[]?

It was empty in the sample. There is nothing to infer from, so the safest type is unknown[] — narrow it yourself.

Can I get type aliases instead of interfaces?

Yes, switch the Declaration option to "type alias". Interfaces are the better default because they can be extended and merged.

Are duplicate names handled?

Yes. Two different shapes that would land on the same name get a numeric suffix so the output always compiles.