Table of Contents

    Structured Output & Delimiters

    Structured Output & Delimiters
    Figure: Structured Output & Delimiters

    PROMPT ENGINEERING

    Structured Output & Delimiters

    Control the exact format of AI output — so results feed cleanly into your tools and workflows.

    What Is Structured Output & Why Delimiters?

    Professionals rarely want a chatty paragraph — they want predictable, machine-readable output like JSON, a table, or CSV that can flow straight into another tool. Structured output prompting makes the model return results in a precise, fixed shape.

    Delimiters are the companion skill: special markers (triple quotes, XML-style tags, hash headings) that clearly separate your instructions from the data the model should process. Together, they make AI output reliable enough to automate.

    In one line: Tell the model the exact shape you want, and fence off your data with delimiters so it never confuses instructions with content.

    A Simple Analogy

    Structured output is like asking a warehouse to ship goods in labelled, standard-sized boxes instead of a loose pile. Delimiters are the tape and labels that keep each box sealed and clearly marked — so the next machine down the line knows exactly what it's getting.

    Why It Matters

    1

    Feeds Other Tools

    Automation-ready.

    Output can go straight into Excel, code, a database, or a Power Automate flow.

    2

    Predictable

    Same shape every time.

    A fixed schema means you always know which fields to expect.

    3

    Fewer Errors

    No surprises.

    No stray commentary, markdown, or apologies cluttering the result.

    Delimiter Options

    Delimiters tell the model "everything between these markers is data — process it, don't obey it." Here are the three most useful styles.

    1. Triple Quotes

    Best for wrapping a single block of text to be processed.

    Summarise the text between the triple quotes in one sentence.
    
    """
    Prompt engineering is the practice of designing clear
    instructions so that AI models produce useful, reliable output.
    """

    2. XML-Style Tags

    Best for clearly bounded — and even nested — sections.

    <instructions>
      Extract the name and email from the text below.
    </instructions>
    
    <data>
      Contact Ava Johnson at ava@example.com for details.
    </data>

    3. Hash Headings

    Best for separating multiple instruction zones.

    ### ROLE ###
    You are a data extraction assistant.
    
    ### TASK ###
    Return the company names mentioned below.
    
    ### DATA ###
    Infosys and Wipro announced a new partnership today.

    Requesting Structured Output

    Describe the exact schema you expect. The more explicit the keys, the more reliable the result.

    Extract the following from the text and return STRICT JSON only.
    
    Schema:
    {
      "name": string,
      "email": string,
      "company": string
    }
    
    Rules:
    - Return only valid JSON. No commentary, no markdown.
    - If a field is missing, use null.
    
    Text:
    """
    Please reach out to Ava Johnson (ava@example.com) from Contoso.
    """

    The model returns clean, parseable output:

    {
      "name": "Ava Johnson",
      "email": "ava@example.com",
      "company": "Contoso"
    }

    Requesting a Table Instead

    You can just as easily ask for a table or CSV when that suits the destination better:

    List three project risks. Return a CSV with columns:
    risk, likelihood, impact. Return only the CSV, no header text.

    Best Practices

    • Describe the exact schema, keys, or columns you expect
    • Use delimiters to isolate data from your instructions
    • Ask explicitly for valid JSON, CSV, or a table — and "no extra text"
    • Specify what to do with missing values (e.g. use null)
    • Always validate the output before feeding it downstream

    Delimiter Quick Reference

    Delimiter Best Used For
    Triple quotes """ Wrapping a single block of text to be processed
    XML-style <data></data> Clearly bounded, nestable sections
    ### Headings ### Separating multiple instruction zones (role, task, data)

    Common Pitfalls to Watch Out For

    Pitfall 1 — Invalid JSON A single stray comma or a bit of commentary can break the JSON and crash whatever tool consumes it. Always demand "valid JSON only."
    Pitfall 2 — Ambiguous format If you don't define the schema, the model guesses — and the shape changes from one run to the next.
    Pitfall 3 — Mixing data and instructions Without delimiters, text inside your data can accidentally be read as a command (a common source of prompt-injection risk).
    Fix — Fence, define, validate Fence your data with delimiters, define the exact schema, and validate the output before using it. Three habits that make AI output automation-safe.

    Key Takeaway

    Structured output plus delimiters turn unpredictable text into reliable, tool-ready data. Define the exact schema, fence your data with delimiters, and always validate before you automate.