---
title: "Question and Answer Schema API with JSON-LD · Unhead"
canonical_url: "https://unhead.unjs.io/docs/typescript/schema-org/api/schema/question"
last_updated: "2026-09-05T16:41:02.411Z"
meta:
  description: "Create Question and Answer schema with defineQuestion. Learn accepted answers, stable IDs, page relationships, and TypeScript examples."
  "og:description": "Create Question and Answer schema with defineQuestion. Learn accepted answers, stable IDs, page relationships, and TypeScript examples."
  "og:title": "Question and Answer Schema API with JSON-LD · Unhead"
---

Home

`
Unhead on GitHub

Switch to TypeScriptSwitch to VueSwitch to ReactSwitch to SvelteSwitch to Solid.jsSwitch to AngularSwitch to Nuxt

**Schema**

# **Question and Answer Schema API with JSON-LD**

[Copy for LLMs](https://raw.githubusercontent.com/unjs/unhead/refs/heads/main/docs/schema-org/5.api/9.schema/question.md)

## **Implementation overview **

Use defineQuestion() to connect a question with its accepted answer in JSON-LD. This reference covers required values, generated identifiers, WebPage relationships, aliases, and complete TypeScript examples.

## Schema.org Question

- **Type**: `defineQuestion<T extends Record<string, any>>(input?: Question & T)`  
  Describes an individual question. It is commonly used on an `**FAQPage**`.

## Useful Links

- [**~~Schema.org Question~~**](https://schema.org/Question)
- [**~~Recipe: FAQ~~**](https://unhead.unjs.io/docs/schema-org/guides/recipes/faq)

## Question and answer properties

- **name** `**string**` or **question** `**string**`  
  The text content of the question.
- **acceptedAnswer** `**string | Answer**` or **answer** `**string**`  
  The text content of the answer.

## Examples

### Minimal

```
defineQuestion({
  name: 'What is the meaning of life?',
  acceptedAnswer: '42',
})
```

## Defaults

- **@type**: `**Question**`
- **@id**: `**${canonicalUrl}#/schema/question/{n}**`
- **inLanguage**: `**inLanguage**` from resolved page metadata *(see: [**~~Schema.org Params~~**](https://unhead.unjs.io/docs/schema-org/guides/core-concepts/params))*

## Resolves

See [**~~Global Resolves~~**](https://unhead.unjs.io/docs/schema-org/guides/get-started/overview#how-does-schemaorg-get-page-data) for full context.

- converts the `**question**` alias to `**name**` and the `**answer**` alias to `**acceptedAnswer**`
- converts a string answer to an [**~~Answer~~**](https://schema.org/Answer) object
- assigns numbered IDs in registration order when `**@id**` is not provided
- serializes `**dateCreated**` Date objects as ISO 8601 strings

## Relation Transforms

[**~~WebPage~~**](https://unhead.unjs.io/docs/schema-org/api/schema/webpage)

- Each question appends an entry to `**mainEntity**` when the WebPage includes the `**FAQPage**` type

## Types

```
/**
 * A specific question, e.g., from a user seeking answers online or collected in a Frequently Asked Questions (FAQ) document.
 */
export interface QuestionSimple extends Thing {
  /**
   * The text content of the question.
   */
  name?: string
  /**
   * An answer object, with a text property which contains the answer to the question.
   */
  acceptedAnswer?: NodeRelation<Answer | string>
  /**
   * The language code for the question; e.g., en-GB.
   */
  inLanguage?: string
  /**
   * The number of answers provided for this question.
   */
  answerCount?: number
  /**
   * The date and time the question was created.
   */
  dateCreated?: ResolvableDate
  /**
   * Alias for `name`
   */
  question?: string
  /**
   * Alias for `acceptedAnswer`
   */
  answer?: string
}

/**
 * An answer offered to a question; perhaps correct, perhaps opinionated or wrong.
 */
export interface AnswerSimple extends Thing {
  text: string
}

export interface Answer extends AnswerSimple {}
```

## Related Schemas

- [**~~Person~~**](https://unhead.unjs.io/docs/schema-org/api/schema/person): Question author
- [**~~Article~~**](https://unhead.unjs.io/docs/schema-org/api/schema/article): Related article

[Edit this page](https://github.com/unjs/unhead/edit/main/docs/schema-org/5.api/9.schema/question.md)

[Markdown For LLMs](https://raw.githubusercontent.com/unjs/unhead/refs/heads/main/docs/schema-org/5.api/9.schema/question.md)

**Did this page help you? **

[**Product Schema** Use defineProduct() to add Product structured data for e-commerce pages with pricing, reviews, and availability.](https://unhead.unjs.io/docs/schema-org/api/schema/product) [**Quiz Schema** Add Google Education Q&A structured data with defineQuiz(), including flashcard questions, answers, subjects, and grade alignments.](https://unhead.unjs.io/docs/schema-org/api/schema/quiz)

**On this page **

- [Schema.org Question](#schemaorg-question)
- [Useful Links](#useful-links)
- [Question and answer properties](#question-and-answer-properties)
- [Examples](#examples)
- [Defaults](#defaults)
- [Resolves](#resolves)
- [Relation Transforms](#relation-transforms)
- [Types](#types)
- [Related Schemas](#related-schemas)