Skip to content
Lifetime access to every course you buy · 14-day refund window

DATA & AI · 7 MIN READ · UPDATED 13 OCTOBER 2026

How to Write AI Prompts That Return Structured Output (JSON and Tables)

Friendly paragraphs are fine for reading, but useless when the next step is a spreadsheet, a form or an automation. This guide gives you a five-part prompt pattern that works across AI tools, shows how to ask for JSON or table output, and explains how to check results before anyone relies on them.

Why structured output needs a different prompt

In a chat you can correct the AI on the next turn. In a spreadsheet or no-code workflow, the same prompt may run on hundreds of inputs with nobody watching, so it must be complete on its own. Structured output means fixed field names and predictable values: a category from a closed list, a date in one format, an amount as a plain number. Anything left open tends to come back in a dozen variations.

The pattern below is vendor-neutral. It works in general chat assistants, in AI features built into spreadsheets and in the AI steps of automation platforms. Some tools also let you define output fields or a schema directly; if yours does, use that feature as well, and keep the same discipline in the prompt itself.

The five-part prompt

A reliable prompt has five parts: role, context, task, format and examples. Each removes a different kind of guessing. Keep it short enough that, when an output is wrong, you can see which rule was ignored. Give the task explicit decision rules, such as which category wins when an email mentions both a delivery problem and a refund. Above all, give the model a permitted way to say information is missing: “If no order number appears, use null. Do not guess.” That one sentence offers an alternative to inventing a plausible value.

  • Role: the kind of assistant, tied to your business
  • Context: what a new temporary colleague would need to know
  • Task: one instruction, with decision rules and a rule for missing information
  • Format: field names, allowed values and “no other text”
  • Examples: one to three invented cases, including a tricky one

Design the fields before the wording

Decide the output before writing the prompt. For each field, note its name, its type (text, number, date or one of a list), the allowed values and what to return when the value is missing. Use one date format, such as 2026-10-13, so a spreadsheet sorts correctly. Write amounts as plain numbers, with the currency in its own field. Close every category list and include “other”, so unexpected inputs still have a valid home.

Then choose the shape. JSON, a plain-text format of named fields, suits automation platforms, which split it into separate values. A tab- or pipe-separated table suits pasting into a spreadsheet, provided the column order is fixed and values never contain the separator. Labelled lines, such as “Category: …”, are a simple middle ground for short outputs that a person will read.

A complete prompt you can adapt

Here is the five-part pattern applied to those fields. Replace the business details, rules and example with your own, and keep the instruction that values must come only from the email. When you test it, paste in real messages with names, phone numbers and addresses removed, for the reasons covered in the privacy section below.

Validate the output before you trust it

Treat every response as unverified until it passes two kinds of check. Structural checks confirm that the output parses, required fields are present, dates and numbers are valid, and categories come from the allowed list. Automation platforms can do this with filter or condition steps, spreadsheets with data validation or a helper column. Anything that fails goes to a review queue, never silently into your records.

Content checks ask whether the values are true. AI models can produce fluent, confident errors: a date shifted by a day, a summary that adds a promise nobody made, an amount that is not in the source. Reduce the risk by asking the model to quote the sentence each value came from, and keep tasks narrow; extracting six fields is usually more reliable than extracting, summarising and drafting a reply in one step.

What not to paste into an AI tool

With most cloud AI tools, whatever you paste goes to at least one outside company, often more, because automation platforms pass data on to their AI provider. Retention, training use and processing location depend on the service and the plan, and can differ between consumer and business plans of the same product. Read the current terms for the plan you actually use, or ask whoever manages IT in your organisation.

Unless your organisation has approved a tool for it, keep the categories below out. A useful test: if you would not forward it to an outside contractor without an agreement, do not paste it. For personal data, send only what the task needs: replace names and contact details with placeholders such as [NAME], or pass a reference ID and look the person up in your own system afterwards.

  • Passwords, API keys and access codes
  • Payment card, bank account and government ID numbers
  • Health and other sensitive personal data
  • Other people’s personal data beyond what the task needs
  • Confidential client documents, unpublished financial results and HR matters

Keep a person in the loop, and test properly

Match review to risk. Spot-check internal category labels weekly; have a person read every draft customer reply before it is sent. For amounts, legal wording or anything health-related, combine an automatic check against the source with a human check. Treat any confidence field as a routing hint, not a guarantee, and place the review point immediately before any action that leaves your organisation or cannot be undone.

Before connecting a prompt to anything, test it on 15 to 20 real inputs with personal details removed, counting structural failures separately from content errors. A missing field usually needs a clearer format instruction; a wrong value needs better input, a sharper rule or a human check. Keep a dated copy of every prompt version. The AI Automation Without Code course turns this pattern into complete no-code workflows with review queues and measured time savings.

Questions

Should I ask the AI for JSON or a table?

Use JSON when an automation platform will split the output into fields, and a fixed-column table when you will paste results into a spreadsheet. Define field names and allowed values first.

Can I trust the confidence level an AI reports?

Only as a routing hint. Models can be confidently wrong, so send low-confidence items to review and keep proportionate checks on the rest.

Is it safe to paste customer emails into an AI tool?

Only if your organisation has approved that tool for customer data. Even then, remove anything the task does not need, such as names, phone numbers and addresses.

Examples in this guide use fictional businesses and figures. Rules on tax, privacy and marketing differ by country; check what applies to you.

More free guides