PlaybookPrompts

Convert a raw API response into a typed data schema

Coding & Development apitypesintegration

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.

Prompt
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.
Variables to fill in
  • {{TARGET_LANGUAGE}}
  • {{RAW_JSON}}
  • {{NULLABLE_CONTEXT}}

How to use this prompt

  1. Copy the prompt above (Copy button on the top-right).
  2. Replace each {{VAR}} with your own value. Variables: {{TARGET_LANGUAGE}}{{RAW_JSON}}{{NULLABLE_CONTEXT}}.
  3. Paste it into one of the recommended tools below.
  4. 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.

Heads up: some of the links on this page are affiliate links — meaning we may earn a commission if you sign up after clicking, at no extra cost to you. We only recommend tools we'd put on our own stack. You can see our full affiliate disclosure here.

Pair this prompt with a tool

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.