• Module 2 · Core Techniques
  • 2 min read · about 20 min lab
  • Builds: Your own prompt library

AI Output Formatting: Get JSON, Markdown Tables, and Custom Formats Reliably

Control the structure of the answer: JSON, Markdown tables, and custom formats.

Key takeaway & what you'll build

Say exactly what shape you want the answer in: the format, the fields or columns, the length, and what to leave out. For JSON, show the structure with one example object; for tables, name the columns. A precise format makes output you can paste straight into a spreadsheet, document, or tool.

You'll build: Your own prompt library

The format is part of the prompt

If you don't say what shape the answer should take, the model picks one, usually a friendly introduction, a numbered list, and an offer to help further. That's fine to read and painful to reuse.

Be specific about the shape

Name four things:

  1. The format: JSON, a Markdown table, a bulleted list, CSV, plain text
  2. The fields or columns, by name
  3. The size: how many items, how long each one is
  4. What to leave out: "return only the table", "no introduction"

JSON: show the structure

Return product data for a water bottle, a yoga mat, and a jump rope as a JSON array.
Use exactly this structure for each item and return only the JSON, with no other text:

{"name": "string", "category": "string", "price_usd": number, "tagline": "string under 60 characters"}

Showing one example object is few-shot prompting for structure: it fixes the field names and types. If the data must be real, such as your actual prices, put it in the input; otherwise the model makes it up.

Markdown tables: name the columns

"Compare these three plans as a Markdown table with the columns Plan | Monthly price | Best for | Main limit. One row per plan. No text before or after the table."

Tables are ideal for comparisons and paste cleanly into most documents.

Custom formats

You can define any format by example:

For each idea, use exactly this format:
IDEA: <one sentence>
WHY IT WORKS: <one sentence>
FIRST STEP: <one action>

Labelled fields like these are easy to scan and easy to split into separate cells later.

When the format breaks

  • Extra chatter around the output? Add "Return only the [format]. No other text."
  • Fields missing or renamed? Show the example structure, not just a description.
  • Too long? Give an exact count: "exactly five rows", "under 20 words each."

Try it

Pick some information you use regularly, such as a list of clients, products, or tasks. In Ask Ace, ask for it as a Markdown table with named columns, then as JSON with an example object. The lab is next.

Before and after

Product data as JSON (example)

Before

Prompt

Give me product info for a water bottle, a yoga mat, and a jump rope.

Output

Sure! Here's some information about each product:

1. Water bottle: A reusable bottle that keeps drinks cold for hours...
2. Yoga mat: A non-slip mat that provides cushioning...
3. Jump rope: An adjustable rope great for cardio...

After

Prompt

Return product data for a water bottle, a yoga mat, and a jump rope as a JSON array. Use exactly this structure for each item and return only the JSON, with no other text:

{"name": "string", "category": "string", "price_usd": number, "tagline": "string under 60 characters"}

Output

[
  {"name": "Steel Water Bottle", "category": "Hydration", "price_usd": 24, "tagline": "Cold for 24 hours, light enough to forget"},
  {"name": "Grip Yoga Mat", "category": "Yoga", "price_usd": 39, "tagline": "Stays put in every pose"},
  {"name": "Speed Jump Rope", "category": "Cardio", "price_usd": 15, "tagline": "Ten minutes, full workout"}
]

Showing the structure and saying "return only the JSON" turns a chatty answer into data a tool can read. The prices are invented by the model, so give it real ones when they matter.

Hands-on lab

Format Like a Pro

Write three prompts that produce the same product information for three items in three formats: JSON (with the structure shown), a Markdown table (with named columns), and a custom format of your choice. Then reflect on which format was easiest for the model to get right and which is most useful for developers versus non-technical readers.

What the AI grader checks for

  • JSON prompt (25%): Clearly requests JSON, specifies the structure with named fields (ideally an example object), and asks for JSON only.
  • Table prompt (25%): Requests a Markdown table with explicitly named columns and a defined number of rows.
  • Custom format (25%): Defines a third format clearly enough that the model could follow it exactly, such as labelled fields or a template.
  • Reflection quality (25%): Compares the formats thoughtfully, including who would use each and why.

Ask the AI course tutor

The tutor knows this whole course. Pick a question to start a conversation about this lesson.