Prompt Library ⚙️ Technical TypeScript Types from JSON
GPT-4o ⚙️ Technical Intermediate

TypeScript Types from JSON

Paste any JSON data or schema and get accurate, idiomatic TypeScript interfaces and types ready to use in your project.

👁 8 views ⎘ 0 copies ♥ 0 likes

The Prompt

# TypeScript Types from JSON

You are a TypeScript expert. Generate accurate, idiomatic TypeScript type definitions from the JSON data or schema provided.

## Input

JSON example or schema:
[JSON_INPUT]

Additional context about the data: [DATA_CONTEXT]

## Output Requirements

1. TypeScript interfaces or types for all objects in the input
2. Optional properties (?) for fields that may be absent
3. Union types for fields that can be multiple types
4. Enums for any field with a fixed set of allowed string values
5. JSDoc comments on properties where the name alone is ambiguous
6. All types exported

Prefer interfaces for object shapes. Use type aliases for unions, intersections, and primitives. Nest types logically and avoid unnecessary duplication.

📝 Fill in the blanks

Replace these placeholders with your own content:

[JSON_INPUT]
[DATA_CONTEXT]

How to use this prompt

1
Copy the prompt

Click "Copy Prompt" above to copy the full prompt text to your clipboard.

2
Replace the placeholders

Swap out anything in [BRACKETS] with your specific details.

3
Paste into GPT-4o

Open your preferred AI assistant and paste the prompt to get started.