---
schema_version: "1"
id: da35f5ce1a22a93aa9c30c570acecd1adb860c26922d2cde3c1e5412642cf4a8
title: Use Structured Outputs to Format Model Responses
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/ai/264-0-0/prompt_builder_use_structured_outputs_responses.md
canonical_url: https://help.salesforce.com/s/articleView?id=ai.prompt_builder_use_structured_outputs_responses.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: fe4934cbf54918e0e5839b922f293bb3ef359d1ff23a2a7fd14a563afe6048f7
description: Structured Output in Prompt Builder ensures models return responses in a consistent JSON or HTML format, improving reliability for workflows, integrations, and UI rendering.
products:
  - Agentforce
  - Cross Cloud
release: "264"
---
# Use Structured Outputs to Format Model Responses

Structured Output in Prompt Builder ensures models return responses in a consistent JSON or HTML format, improving reliability for workflows, integrations, and UI rendering.

### Required Editions

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small edition"><colgroup><col></colgroup><tbody><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: Lightning Experience</td></tr><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: <strong>Enterprise</strong>, <strong>Performance</strong>, and <strong>Unlimited</strong> Editions with the Einstein for Platform, or Einstein or Agentforce for Sales or Service add-on, or Agentforce Foundations</td></tr></tbody></table>

Structured Outputs defines the format of model responses by using JSON or HTML. This feature provides structure when your workflow, integration, or UI requires consistent formatting for rendering or parsing data.

Instead of relying on user-written prompt instructions, Structured Outputs applies system-level instructions and sets metadata at the template level. This control improves reliability when working with tools like Flow or Agents.

## Select the Expected Response Format

Selecting JSON applies special instructions and syntax checks to help return clean, valid JSON. When you select HTML, the system signals the model to respond by using HTML formatting. Set the format one time per template. The selection applies to every prompt sent that uses that template, giving you consistency across use cases.

**Format: Default**

By default, models often use Markdown for light formatting, like bold, italic, or bullet points. Earlier versions of Prompt Builder showed this formatting as raw text. The current version renders Markdown as styled output, improving readability and making responses easier to interpret. Prompt Builder uses the same rendering component as an agent, so the formatting matches what users see in a real-world situation.

**Format: JSON**

Selecting JSON applies special instructions and syntax checks to help return clean, valid JSON.

![Important](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ai-generative_ai-264-0-0-production-enus/f8ef6498-d7b2-44e3-9b34-ffd5a850aae9/images/icon_important.png)

Important JSON response format returns a single JSON object. To generate a JSON array, use the Default format and specify the array structure in your prompt instructions.

View JSON responses only in the raw view. Fields don't render formatted text, such as Markdown and carriage returns, `\n`, `\r`. Models performance varies when generating JSON. Thorough testing is important to increase accuracy and consistency. For the best results, select a Lightning Type to enforce the JSON schema. If you don't select a Lightning type, include an example of your JSON structure in your prompt instructions.

When by using JSON as the response format, you can optionally select a Lightning Type to enforce a predefined output schema. Lightning Types define exact fields, data types, and required values that the model returns.

Without a Lightning type, JSON responses rely on prompt instructions alone. While the system applies syntax checks to help ensure valid JSON, the structure itself varies between responses. Lightning Types remove this variability by shifting schema definition from prompt instructions to system-enforced metadata. After you select a Lightning type:

- Prompt Builder instructs the model to match the predefined schema exactly
- The model populates values instead of determining structure
- Responses are more reliable for flows, Agents, and integrations

Select a Lightning type when you consume JSON output via:

- Automation or orchestration tools
- Downstream integrations
- UI components that require consistent data structures

You can use Lightning Types in two ways:

- Object-based Lightning Types, created directly in Prompt Builder by using the Lightning Type Builder
- Apex-based Lightning Types are created in Setup by using Apex classes and reused across features

Select either Lightning Type when configuring JSON output for a prompt template.

**Format: HTML**

Selecting HTML configures the template to return and show structured, styled content. Prompt Builder:

- Tags the template with `format = rich text`
- Instructs the model to return HTML-formatted output
- Uses the `lightning-formatted-rich-text` Lightning Web Component to render responses

Prompt Builder uses the Lightning Web Component `lightning-formatted-rich-text` to render the response from the model.

- This component supports a subset of HTML tags and doesn’t behave like a full browser.
- Prompt Builder preserves unsupported HTML tags in the model response, but doesn’t render them in the view.
- All demasked data appears in the Response section. To view the mapping between the original and masked values, open the Masking Details (![Shield icon](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ai-generative_ai-264-0-0-production-enus/f8ef6498-d7b2-44e3-9b34-ffd5a850aae9/generative_ai/images/prompt_builder_gtk_shieldIcon.png)) window in the Response section.
- Refer to the [Salesforce Component Library documentation](https://developer.salesforce.com/docs/component-library/bundle/lightning-formatted-rich-text/documentation) for a complete list of supported tags. Use the rich text output only within Salesforce, as it isn’t optimized or validated for full rendering on external web platforms.