JSON to TypeScript
Convert JSON to TypeScript interfaces or type aliases instantly. Handles nested objects, arrays, unions, and null types. Free online tool for frontend developers.
Paste any JSON object and get fully-typed TypeScript interfaces in seconds. The generator handles nested objects (each becomes a separate named interface), arrays of objects, mixed primitives, and null fields — ready to drop straight into your codebase.
Related tools
Frequently asked questions
How do I convert JSON to a TypeScript interface?
Paste your JSON into the left panel and the TypeScript interface appears instantly on the
right. Every key becomes a typed property, nested objects become separate named interfaces,
and arrays of objects generate array types like Variant[]. You can customise the root interface name and choose between
interface and
type output.
What is the difference between a TypeScript interface and a type alias?
Both describe the shape of an object. interface supports declaration merging and is preferred by most style guides for object shapes.
type is
more flexible — it can represent unions, intersections, and primitives. For objects derived
from JSON, either works; the "Both" option exports both so you can choose later.
How are nested objects handled?
Each nested object becomes a separate exported interface named after its key in PascalCase.
For example, a key shippingAddress becomes interface ShippingAddress, and the parent interface references it by name. This prevents deeply inlined types and
encourages reuse.
What does the "optional nullable fields" toggle do?
When enabled, any field whose JSON value is null gets the optional modifier ? in the interface. This signals that the field may not always be present or may be null,
which is common in API responses where optional fields are omitted or set to null.
How are arrays handled — especially mixed-type arrays?
Arrays of a single object shape become ClassName[] where the class name is singularized from the key. Arrays of uniform primitives become
string[], number[], etc. Mixed arrays become union arrays like (string | number)[] and fully heterogeneous arrays become unknown[].
Is the generated TypeScript production-ready?
The output is valid TypeScript that you can copy directly into your project. For
production use, review fields that resolved to null or unknown — these occur when the JSON value was null or an empty array, so the generator couldn't
infer the intended type. Replace them with your intended types manually.