Paste TypeScript interface, type alias, enum or class declarations and get an example JSON document that satisfies them. Literal unions, Record, utility types like Pick, Omit and Partial, and interfaces chained with extends are all followed and filled in.
Use it before an API exists to prepare MSW or json-server mock data, to create Storybook props, or to show the backend team exactly which shape you want them to send.
types.ts. export, import and function declarations may be mixed in; only type declarations are read.enums so they get filled. Type names missing from the input become null.type UserPage = Page<User>, is preferred over the generic declaration itself.HttpResponse.json(...), a test fixture or Storybook args, then adjust the values.type Channel = "email" | "sms" | "push";
enum Priority { Low = "low", High = "high" }
interface Notification {
id: string;
channel: Channel;
priority: Priority;
recipient: { userId: number; locale?: string };
payload: Record<string, string>;
readAt: Date | null;
meta: Pick<Audit, "createdBy">;
}
interface Audit { createdBy: string; createdAt: Date }{
"id": "",
"channel": "email",
"priority": "low",
"recipient": {
"userId": 0,
"locale": ""
},
"payload": {
"key": ""
},
"readAt": "1970-01-01T00:00:00.000Z",
"meta": {
"createdBy": ""
}
}Channel is a string literal union, so it takes its first value "email"; the string enum Priority takes its first member value "low". Record<string, string> becomes an object with a single "key", Date | null resolves to the non-null side as an ISO string, and Pick<Audit, "createdBy"> keeps only the picked key. The optional locale? is included as well.
string → "", number/bigint → 0, boolean → false, any/unknown → null, Date → 1970-01-01T00:00:00.000Z (the Date.toJSON() format).null/undefined, and intersections (A & B) and interface ... extends merge properties.enum uses its first member's value, or 0 for a numeric enum without initializers.Array<T> and Set<T> get one sample element; tuples get a value per position; Record<K, V>, Map and index signatures become {"key": V}.Partial, Required, Readonly, NonNullable, Pick and Omit.static fields, get/set accessors and @Exclude() fields are excluded.children: TreeNode[]) are cut off as empty arrays.Before the backend is ready, generate mock data from the API response types. The UI can be built first, and switching to the real API later keeps the same types.
Create a default object from a component's props type for story args or React Testing Library render data. Every required property is present, so there are no type errors to chase.
Turn a frontend request type into JSON and paste it into an API design doc or issue, so backend developers who don't use TypeScript can read the structure immediately.
?) are always included; delete keys yourself to test responses where they are absent.type UserPage = Page<User>, items: T[] is filled with User, and defaults like <T = string> apply when no argument is given. Conditional types inside generics are still not evaluated.T["key"], conditional types and template literal types are not evaluated.name = "kim", retries = 3) uses that value; other initializers like new Date() only hint at the type.z.infer out as a plain interface.Map and Set are shown as an object and an array, but JSON.stringify turns both into {}, so prefer Record or arrays in response types.Date comes out as a string?Yes. JSON.stringify replaces a Date with its toJSON() result, an ISO 8601 string. The receiving side still gets a string, so either type it as string or parse it.
status: "active" | "inactive" get?The first literal in declaration order, "active". Reorder the union if you'd rather show a different value.
Class declarations and decorators are parsed, so DTOs annotated with class-validator decorators convert fine, and class-transformer @Exclude() fields are left out.
Use the JSON → TypeScript page for the opposite direction. Separate pages also generate JSON from TypeORM, Sequelize and Mongoose models.