When would you ask for JSON, XML tags, or markdown as your output format?
Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.
Model answer: the part to lead with
Three formats, three consumers. JSON when a program parses the output. XML-style tags when you want a few loosely typed sections and the content is messy. Markdown when a human reads it.
Full worked answer
Three formats, three consumers. JSON when a program parses the output. XML-style tags when you want a few loosely typed sections and the content is messy. Markdown when a human reads it.
JSON is the default for machine consumption, and it should be paired with schema-constrained decoding rather than hope. Its weakness is escaping: a long code snippet or a document excerpt inside a JSON string becomes a swamp of \n and \", and models make more mistakes the more escaping you demand. Deep nesting and unions also cost quality.
XML-style tags are underrated. They are self-delimiting, so content containing braces, quotes, or newlines needs no escaping. Nesting is visually obvious to the model. Partial output is still salvageable, which matters when you stream or hit a length cap. They shine in two places: structuring the input (<documents>, <examples>, <instructions>) and structuring outputs where you want free-text sections, for example <reasoning>...</reasoning><answer>...</answer>. Anthropic's models in particular are documented as responding well to XML tags, and every frontier model handles them fine.
Markdown is for human-facing chat surfaces. Do not ask for it when a parser is downstream, and never nest a markdown blob inside a JSON field if you can avoid it.
The misconception worth flagging: asking for JSON because it looks rigorous, when nothing parses it. You pay tokens, add a failure mode, and constrain the model's phrasing for no benefit. Heavy format constraints can measurably degrade content quality on reasoning-flavoured tasks, so the rule of thumb is to pick the loosest format your consumer can actually parse. If you only need one value, ask for one value on one line and read it.
A hybrid that works well in practice: XML tags at the top level with a JSON payload inside a single <result> tag, so the model can think in prose and still hand you something typed.
What a good answer covers
- JSON when a program parses the output
- XML-style tags when you want a few loosely typed sections and the content is messy
- JSON is the default for machine consumption, and it should be paired with schema-constrained decoding…
- Its weakness is escaping: a long code snippet or a document excerpt inside a JSON string becomes a swamp…
- Deep nesting and unions also cost quality
Key terms: JSON · XML-style tags · Markdown
Interviewer follow-ups to expect
Why does regex or schema-heavy constrained decoding sometimes hurt answer quality, and how do you mitigate it?
How would you make streaming output usable when the format is JSON?
Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep