JSON or XML Tags for LLM Output: The Format That Holds Under Pressure A developer proposes combining XML tags as delimiters with JSON payloads to handle messy LLM output, using tags like to extract clean JSON from model rambling. The approach addresses common parsing failures caused by preambles, sign-offs, and markdown code fences, while raw JSON mode is preferred when the API supports structured output. XML tags are recommended for multi-part responses or chain-of-thought tasks where reasoning and payload must be separated. Your extraction endpoint has run clean for weeks. Then a support ticket arrives in mixed German and English, the model decides to be helpful, and the response comes back as: Here's the JSON you asked for: {"name": "Müller GmbH", "role": "Lead"} Let me know if you need anything else json.loads throws. Your parser sees the friendly preamble, the friendly sign-off, and dies on the first character. The data was right there. The format around it was wrong. This is the recurring fight with structured LLM output, and it splits into two separate decisions people tend to blur together: what shape the data takes, and what wraps it so you can find it. JSON and XML tags answer different halves of that question. JSON is a data format. It describes a payload: keys, values, arrays, nesting. XML tags, the way most people use them in prompts, are a delimiter. They mark where a span starts and ends so you can slice it out of a stream of text. When someone asks "JSON or XML for LLM output," they are usually conflating those jobs. The honest answer is that you often want both: an XML tag as the envelope, JSON as the letter inside it.