TypeScript Type Generator
Generate TypeScript types and interfaces from JSON data, API responses, or plain English descriptions.
The Prompt
(2 messages)You are a TypeScript expert. Generate precise, well-structured type definitions from the provided input. Guidelines: - Prefer interfaces for object shapes that may be extended; use type aliases for unions, intersections, and mapped types - Use readonly for fields that shouldn't be mutated - Use string literal unions instead of plain string where the values are known - Add JSDoc comments on non-obvious fields - Infer optional fields (?) when values could be null or absent - Use utility types (Pick, Omit, Partial, Required) to reduce duplication - Generate related types (e.g., CreateInput, UpdateInput) when useful
Generate TypeScript types from this input: Input type: {{input_type}} Input: {{input}}
Variables
Fill in these inputs to customize your output:
{{input_type}}Example: JSON API response
{{input}}Example: { "id": "inv_28hd93", "status": "paid", "customer": { "id": "cust_19x8", "name": "Acme Corp", "email": "billing@acme.com" }, "line_items": [ { "description": "Pro Plan - Monthly", "quantity": 1, "unit_price": 4900, "amount": 4900 }, { "description": "Additional seats (3)", "quantity": 3, "unit_price": 1200, "amount": 3600 } ], "subtotal": 8500, "tax": 0, "total": 8500, "currency": "usd", "created_at": "2026-01-15T10:30:00Z", "paid_at": "2026-01-15T10:31:12Z" }
Example Output
Here's what this prompt generates with the sample inputs:
interface Customer {
readonly id: string
name: string
email: string
}
interface LineItem {
description: string
quantity: number
/** Price in cents */
unit_price: number
/** Total for this line (quantity × unit_price), in cents */
amount: number
}
type InvoiceStatus = 'draft' | 'open' | 'paid' | 'void' | 'uncollectible'
type Currency = 'usd' | 'eur' | 'gbp'
interface Invoice {
readonly id: string
status: InvoiceStatus
customer: Customer
line_items: LineItem[]
/** Amount in cents before tax */
subtotal: number
/** Tax amount in cents */
tax: number
/** Total amount in cents (subtotal + tax) */
total: number
currency: Currency
created_at: string
paid_at: string | null
}
/** Fields required when creating a new invoice */
type CreateInvoiceInput = Omit<Invoice, 'id' | 'status' | 'subtotal' | 'tax' | 'total' | 'created_at' | 'paid_at'>
/** Fields that can be updated on an existing invoice */
type UpdateInvoiceInput = Partial<Pick<Invoice, 'status' | 'line_items' | 'customer'>>Configuration
Optimized settings included when you add this prompt. You can adjust them later.
Provider
OPENAI
Model
gpt-4.1
Temperature
0.2
Ready to use this prompt?
Add it to your workspace, customize the inputs, and generate your own results.
Use this prompt — freeMore prompts
Coding
Coding
Coding