Convert a raw API response into a typed data schema
When integrating a third-party API, turning a raw JSON response into a typed schema (TypeScript interface, Pydantic model, Go struct) saves hours and prevents runtime errors. This prompt does it systematically.
You are a backend engineer integrating a third-party API. I have a raw JSON response and I need you to produce a typed schema for it.
Target language / type system: {{TARGET_LANGUAGE}} (e.g. TypeScript interfaces, Python Pydantic v2, Go structs, Zod schema)
Raw JSON response:
```json
{{RAW_JSON}}
```
Additional context about nullable or optional fields: {{NULLABLE_CONTEXT}}
Follow these steps:
1. Parse the JSON and identify every field. For nested objects and arrays, recurse into them.
2. Infer the most specific type for each field (e.g. do not use `any` or `object` if a narrower type is obvious).
3. Flag any field that is `null` in the sample but might be non-null in other responses — mark it as optional/nullable and explain why.
4. Flag any field whose name is a reserved word in the target language and suggest a safe alias.
5. Output the complete typed schema with all nested types defined.
6. After the schema, list any assumptions you made about fields that had ambiguous types in the sample (e.g. a number that could be int or float).
Do not generate serialization/deserialization logic unless I ask. Just the types. {{TARGET_LANGUAGE}}{{RAW_JSON}}{{NULLABLE_CONTEXT}}
How to use this prompt
- Copy the prompt above (Copy button on the top-right).
- Replace each
{{VAR}}with your own value. Variables:{{TARGET_LANGUAGE}}{{RAW_JSON}}{{NULLABLE_CONTEXT}}. - Paste it into one of the recommended tools below.
- Iterate: tighten constraints in the prompt if the output is generic.
Why this prompt is structured this way
The prompt is split into explicit steps because LLMs do better when the path is named, not implied. Each variable forces specificity at the input layer — vague inputs get vague outputs.
Pair this prompt with a tool
Cursor
$20/moAI-first code editor forked from VS Code.
Cursor is VS Code with first-class LLM integration. Multi-file edits, codebase Q&A, autocomplete that's actually useful. The default IDE for many shipping engineers in 2026.
Claude (Anthropic)
$0/mo (Pro at $20)Frontier model with long context and strong reasoning.
Claude (Opus / Sonnet / Haiku tiers) is the assistant favored by writers and engineers who care about reasoning quality and tone. 1M token context on Opus.
ChatGPT (OpenAI)
$0/mo (Plus at $20)The category-defining general-purpose AI assistant.
ChatGPT has the broadest feature surface: image gen, voice, custom GPTs, web browsing, code execution. Often the right default; sometimes beaten on specific tasks by Claude or Perplexity.
The PlaybookPrompts weekly
One short email per week. The five sharpest prompts we found, one tool worth your attention, one anti-pattern to avoid. Unsubscribe in one click.
Newsletter signup is not configured. Set PUBLIC_NEWSLETTER_USERNAME in the build env.