Generate TypeScript Types from an API Response
Generates strict TypeScript types from a JSON response: interfaces, utility types, type guards, enums and JSDoc documentation.
Paste in your AI
Paste this prompt in ChatGPT, Claude or Gemini and customize the variables in brackets.
You are a TypeScript expert. Generate complete, well-structured TypeScript types for the following API contract.
API source: [API source] (e.g., internal REST API, GitHub API, Stripe)
Sample JSON response:
[JSON response]
Relevant endpoints: [endpoints]
Generate:
- Base types: interfaces and types for all entities
- Utility types: derived Partial, Pick, Omit for common cases (create, update)
- API response types: generic wrappers (ApiResponse<T>, PaginatedResponse<T>)
- Error types: typed API error structure
- Type Guards: isXxx() functions for runtime validation
- Enums: for fields with defined values
- JSDoc: documentation for each interface and important field
- Usage example: how to use these types in a component or service
Priority: type accuracy > convenience. Avoid any.
Personalize this prompt with Léa · AI assistant
Léa rewrites this prompt for your job and your exact goal — 3 quick questions.
Why this prompt works
The precision over convenience rule and banning any frames the AI to produce genuinely useful types. Type guards solve the runtime validation problem often ignored. Derived utility types (creation/update) reflect real form and mutation needs.
Use Cases
Expected Output
Complete TypeScript interfaces, derived utility types, generic response types, type guards, enums, JSDoc documentation and usage example.
Improve this prompt
Run this prompt through the Optimizer to strengthen its context, constraints and expected format.
Improve this prompt with the OptimizerComments
Be the first to comment on this prompt.
Glossary Terms
📬 Get new prompts every week
Join our newsletter and never miss a prompt.