
LLMs handle clean, structured text formats best. They process tokens, so any format that converts cleanly to text works, but ones with explicit structure (headings, lists, key-value pairs, nesting) and low noise perform better. Markdown and plain text remain top-tier; here are the strongest alternatives and how they compare.
Strong Formats for LLMs
| Format | Strengths for LLMs | Best For | Limitations / Notes |
|---|---|---|---|
| JSON | Excellent hierarchical structure; models see it constantly in training and APIs. Easy to parse precisely. | Nested data, configs, API responses, structured records | Verbose (higher token count). Deep nesting can still confuse smaller models. |
| YAML | Human-readable + structured; often matches or beats JSON on nested data accuracy in tests. | Configs, hierarchical knowledge, nested objects | Indentation sensitivity; slightly less ubiquitous than JSON in some training mixes. |
| HTML (cleaned) | Semantic tags give strong structure signals. Cleaned/stripped versions perform well on tables and lists. | Web content, documents with layout cues | Raw HTML is noisy and token-heavy (tags, attributes, scripts). Always clean it first. |
| CSV / TSV | Extremely token-efficient for flat tables. Simple and universal. | Spreadsheets, simple tabular data | Loses relationships; lower accuracy than Markdown-style key-value or structured formats in table-understanding tests. |
| XML | Explicit open/close tags help delimit mixed content (reasoning + data). | Structured output, documents needing clear boundaries | More verbose than JSON/YAML. |
| Code files (.py, .js, .ts, etc.) | Models are heavily trained on code; syntax is clear and familiar. | Source code, technical snippets | Language-specific quirks exist, but overall excellent. |
| LaTeX | Strong for math, equations, academic structure. | Scientific papers, technical math content | Can be dense; better when equations stay intact. |
| reStructuredText / Org-mode | Similar lightweight markup to Markdown. | Documentation ecosystems that already use them | Less common than Markdown, so slightly weaker familiarity. |
Formats That Need Conversion (Not Native Strengths)
- PDF: Extremely common source, but LLMs do not read it natively. Text extraction often scrambles reading order (especially multi-column), breaks tables, adds headers/footers as noise, and fails on scans (OCR errors). Complex real-world PDFs remain hard even for frontier multimodal models (benchmarks in 2026 still show low success rates on dense professional documents). Convert to Markdown or clean text whenever possible.
- DOCX / PPTX / XLSX: Similar problem—require extraction. Structure and formatting are partially lost, and token overhead rises. Better to convert to Markdown, JSON, or CSV.
- Scanned images / pure image PDFs: Rely on OCR + multimodal vision models. Quality varies; clean text formats still win for pure reasoning.
Key Patterns from Benchmarks & Practice (2025–2026)
- Markdown consistently ranks highest for general documents on token efficiency, retrieval accuracy (RAG), and final response quality.
- For structured / nested data, YAML and JSON usually lead; Markdown key-value styles can outperform plain CSV on accuracy at the cost of more tokens.
- Token cost matters: Clean Markdown or plain text is cheapest. HTML and raw PDF text can be 50–70%+ more expensive.
- Multimodal models (vision + language) improve PDF and image handling, but the best results still come from converting to clean text formats first.
- Emerging AI-oriented formats (e.g., llms.txt as curated Markdown, DocLang, Open Knowledge Format with Markdown + YAML frontmatter) exist precisely because existing formats lose too much structure or add noise.
Practical Recommendations
- Prose, docs, notes, knowledge bases → Markdown (or plain text if no structure is needed).
- Hierarchical / API-style data → JSON or YAML.
- Flat tables → CSV (or Markdown tables / key-value if accuracy is critical).
- Web pages → Cleaned HTML or convert to Markdown.
- Always prefer converting complex sources (PDF, DOCX) into one of the strong text formats before feeding them to an LLM or RAG pipeline.
In short: LLMs excel at anything that is already clean, structured text with familiar syntax. Markdown remains the sweet spot for most document work; JSON/YAML dominate for data; and binary office formats are best treated as sources to convert rather than as native inputs.