TypeScript Interface vs Type
Interfaces describe object shapes and can be reopened or extended. Type aliases can name any type: objects, unions, arrays, and primitives.
This converter defaults to interfaces for objects. Switch Output to Type aliases to emit export type Name = { ... } instead. Root arrays and unions are always type aliases because they are not a single object.
{ "id": 1, "tags": ["a"] }// Generated locally in your browser. No data was sent to a server.
export interface Node {
id: number;
tags: string[];
}
{ "id": 1, "tags": ["a"] }// Generated locally in your browser. No data was sent to a server.
export type Node = {
id: number;
tags: string[];
};
Edge cases
- A root JSON array cannot be an interface. The output is export type Root = Item[]. That is a language rule, not a limitation of the UI.
- Declaration merging works with interfaces, not with type aliases. If you plan to extend the shape in another file, keep interface mode.
- Neither output runs your code. Both are erased at compile time the same way for object types.
Open the converter with your own payload when you want to copy or download the generated .ts file.