Skip to content

Requesting Specific Output Formats | Lecture 08

Requesting Specific Output Formats

Learn how to request specific output formats from an AI, such as lists, JSON, HTML, and tables. This prompt engineering technique ensures you get structured, usable data. Lecture 08

Telling the AI How to Answer

Welcome back! So far, we’ve told the AI what to do, given it context, and even shown it examples. Now, we need to get specific about the Output Indicator component we briefly mentioned in Lecture 2.

Telling the AI exactly how to format its response is crucial. It saves you time and ensures the output is immediately useful, especially if you need to use the AI’s response in another program or document.

Why Specify the Format?

If you don’t specify a format, the AI will usually respond in plain paragraphs. This is fine for a chat, but what if you need something more structured? By demanding a specific format, you can get data that is:

  • Easy to read: Like a bulleted list or a table.
  • Machine-readable: Like JSON or XML, which can be easily processed by other software.
  • Ready to use: Like HTML for a webpage or a CSV for a spreadsheet.

Example: From Plain Text to a Structured List

Vague Prompt:

Tell me the pros and cons of remote work.

The AI will likely write a few paragraphs, mixing the pros and cons together.

Specific Format Prompt:

List the pros and cons of remote work. Provide your answer in two separate bulleted lists: one for "Pros" and one for "Cons".

This will give you a perfectly organized response that is much easier to read and understand.

Common Formats You Can Request

JSON (JavaScript Object Notation)

This is extremely useful when you want to use the AI’s output in code. It’s a standard data format that many programming languages can understand.

JSON Request
Extract the name, email, and company from the following text. Format the output as a JSON object with the keys "name", "email", and "company".

Text: "My name is Jane Doe, and I work at Acme Inc. You can reach me at jane.doe@acme.com."
Expected AI Response:
{
  "name": "Jane Doe",
  "email": "jane.doe@acme.com",
  "company": "Acme Inc."
}
HTML (HyperText Markup Language)

You can ask the AI to generate code for a webpage. This is great for quickly creating simple web elements.

HTML Request
Create an HTML unordered list (ul) that contains the following three items: Apple, Banana, Orange.
Expected AI Response:
<ul>
  <li>Apple</li>
  <li>Banana</li>
  <li>Orange</li>
</ul>
Tables

You can ask for a table, often using Markdown format, which is easy to copy into many applications.

Table Request
Create a table comparing three popular programming languages: Python, JavaScript, and Java. The columns should be "Language", "Primary Use", and "Ease of Learning".
Requesting Specific Output Formats
Requesting Specific Output Formats

Key Takeaways from Lecture 08

  • Always tell the AI how you want the answer formatted if you need something other than plain text.
  • Be specific in your request (e.g., “bulleted list,” “JSON object,” “HTML table”).
  • For formats like JSON, specify the exact keys you want it to use.
  • This technique makes AI responses more predictable, structured, and useful for other applications.

End of Lecture 08. You are gaining so much control over the AI! Next, we’ll discuss the art of iteration—how to refine your prompts when you don’t get the perfect answer on the first try.

Using Delimiters Your Prompts | Lecture 07

Najeeb Alam

Najeeb Alam

Technical writer specializes in developer, Blogging and Online Journalism. I have been working in this field for the last 20 years.

1 thought on “Requesting Specific Output Formats | Lecture 08”

  1. Pingback: Prompting for Summarization | Lecture 12 - BLOG PK

Comments are closed.