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
| Available in: Lightning Experience |
| Available in: Enterprise, Performance, and Unlimited Editions with the Einstein for Platform, or Einstein or Agentforce for Sales or Service add-on, or Agentforce Foundations |
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.
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-textLightning 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 (
) window in the Response section. - Refer to the Salesforce Component Library 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.

