Font Size:
Ask Joget AI

Output Format

Introduction

The Output Format prompt tells the AI model to return its answer as structured JSON, using the provider's native enforcement mechanism so that the output is reliably machine-readable without post-processing.

Note

A configured AI model is required. Set one up once in the AI Central Config plugin, then return to your agent. Structured output support varies by provider: OpenAI, Anthropic, and Google Gemini support it natively. Verify that your chosen model supports structured output before using JSON Schema mode.

What it does

The Output Format prompt operates at the model configuration level rather than the message level. Instead of adding text to the conversation, it signals to the AI provider that the model's response must be valid JSON, using the provider's own enforcement API (for example, OpenAI's response_format, Gemini's responseMimeType, or Anthropic's instruction-based approach).

Two enforcement levels are available:

  • JSON Object: the model must return any valid JSON object. The structure is not constrained beyond being valid JSON.
  • JSON Schema: the model must return a JSON object that conforms to a JSON Schema definition you provide. This is the strictest mode and is suitable when downstream tools, enhancers, or workflow steps depend on specific field names and types.

The Default (text) option is a no-op. Selecting it is equivalent to not adding this prompt at all.

Because the Output Format prompt enforces structure at the API level, it is more reliable than regex-based parsing in post-processing steps. It eliminates the common failure mode where the model wraps JSON in markdown code fences or adds explanatory text around the JSON block.

This prompt does not describe the output to the model
Output Format constrains the response format, but it does not tell the model what fields to fill in. You must also add a Text Prompt (or another context prompt) that instructs the model on exactly what JSON to produce and what each field means.

When to use it

Use the Output Format prompt when both of the following are true:

  • A downstream step (an enhancer, a tool, a workflow variable, or an integration) consumes the agent's response as structured data.
  • You need a reliable guarantee that the response is valid JSON, not free text that happens to contain JSON.

Typical scenarios include the following:

  • Expense Classifier: In an expense management app, enforce a JSON response with categoryamount, and confidence fields so the Store to Form enhancer can write directly to the expense record without parsing.
  • Contract Extractor: In a contract management app, enforce a schema with effective_dateexpiry_date, and governing_law fields so a workflow step can map the extracted values to process variables automatically.
  • Lead Scoring Agent: In a CRM app, enforce a JSON response with score (integer 0 to 100) and rationale (string) so the JSON Extractor enhancer can reliably pull the score into a form field.
When not to use it
  • When the agent's response is read by a human and does not feed a downstream system, leave this prompt off and let the model reply in natural language.
  • When you only need to extract one value from a free-text response, the JSON Extractor enhancer or the Code Extractor enhancer may be sufficient without constraining the model's entire output.
  • When your configured LLM does not support structured output natively, JSON Schema mode will not work. Use JSON Object mode for a softer constraint, or use an enhancer with regex extraction instead.

Get started

How to use it

To use the Output Format Element, add the Output Format prompt:

  1. Locate the Output Format element under the Prompts section of the palette.
  2. Drag and drop the element into the Drop a prompt here section.

Configure Prompt Properties

To properly integrate and configure the Beanshell, set the following fields:

  • Output Mode: The level of JSON enforcement applied to the model's response. Default (text) (no constraint), JSON Object (any valid JSON) (the model must return valid JSON but the structure is open), or JSON Schema (strict, define structure) (the model must conform to the schema you provide).
  • JSON Schema: The JSON Schema definition the model's response must match. A valid JSON Schema object. Shown and required only when the Output Mode is JSON Schema (strict, define structure). Leave blank for JSON Object mode.

Samples

Enforcing a schema for expense classification
Output Mode: JSON Schema (strict, define structure)
JSON Schema:
{
  "type": "object",
  "properties": {
    "category": {
      "type": "string",
      "enum": ["travel", "meals", "accommodation", "software", "other"]
    },
    "amount": {
      "type": "number"
    },
    "confidence": {
      "type": "number",
      "minimum": 0,
      "maximum": 1
    }
  },
  "required": ["category", "amount", "confidence"]
}

Best Practices

  • Always pair this prompt with a Text Prompt. The Output Format prompt enforces the response shape but says nothing about content. Without a Text Prompt instructing the model on what fields to populate and what values to produce, the model returns a structurally valid but semantically empty JSON object.
  • JSON Schema mode requires provider support. Not all LLM providers implement schema-constrained output. If your provider does not support it, the schema is ignored or the call fails. Test with your specific model before relying on strict schema enforcement in production.
  • Keep schemas focused. A schema with dozens of fields, deeply nested objects, and complex constraints is harder for the model to satisfy reliably. Start with the minimum fields your downstream step actually needs.
  • JSON Object mode is a lighter-weight alternative. When you need the response to be parseable JSON but do not need a specific shape, JSON Object mode is more broadly supported across providers and less likely to cause API errors.
  • Downstream enhancers become simpler. Once Output Format is in place, the Store to Form Enhancer, the Store to Agent Variable, and the JSON Extractor enhancer all receive clean, predictable JSON rather than needing to parse it from free text.
Created by Debanraj Ravindran Last modified by Debanraj Ravindran on Jul 10, 2026