{"data":{"slug":"github-xberg-io-xberg-plugin-ai-rulez-skills-xberg-picking-a-format-6cb4b3f3ba7d","title":"Choosing the Right Output Format for Document Extraction","summary":"Select the optimal format for extracted documents based on the downstream consumer (LLM, parser, archive) to ensure compatibility and efficiency.","url":"https:\/\/skillshunter.net\/skills\/github-xberg-io-xberg-plugin-ai-rulez-skills-xberg-picking-a-format-6cb4b3f3ba7d","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-xberg-io-xberg-plugin-ai-rulez-skills-xberg-picking-a-format-6cb4b3f3ba7d","markdown_url":"https:\/\/skillshunter.net\/skills\/github-xberg-io-xberg-plugin-ai-rulez-skills-xberg-picking-a-format-6cb4b3f3ba7d.md","download_url":"https:\/\/skillshunter.net\/skills\/github-xberg-io-xberg-plugin-ai-rulez-skills-xberg-picking-a-format-6cb4b3f3ba7d\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_note":"The skill requires the user to choose between formats like plain text, markdown, JSON, or DocTags based on the downstream consumer, such as an LLM, parser, or archive system.","instructions":"---\ntype: Playbook\ntitle: Picking A Format\ndescription: Use when choosing an output format for extracted documents \u2014 plain text, markdown, djot, HTML, JSON, or DocTags. Maps consumer (LLM, parser, archive) to the right `--format` \/ `--content-format` pair.\nx-ai-rulez:\n  kind: skill\n  id: xberg-picking-a-format\n  metadata:\n    name: xberg-picking-a-format\n---\n\n# Picking a format\n\nXberg has two orthogonal format knobs. Get them right up front and the\ndownstream code stays simple.\n\n| Knob                | What it controls                                  | Values                                 | Default          |\n| ------------------- | ------------------------------------------------- | -------------------------------------- | ---------------- |\n| `--format`          | How the CLI prints the result                     | `text`, `json`, `toon`                 | `text` (`extract`), `json` (`batch`) |\n| `--content-format`  | How extracted content is rendered inside `result` | `plain`, `markdown`, `djot`, `html`, `json`, `doctags` | `plain`     |\n| `--token-reduction` | Strip whitespace \/ boilerplate for LLM contexts   | `off`, `light`, `moderate`, `aggressive`, `maximum` | `off`  |\n\n`--format json` returns an envelope wrapping the `ExtractedDocument` \u2014 the\ndocument lives under `.result` for `extract` and under `.results[]` for\n`batch`, with `content`, `metadata`, `tables`, and `images` as fields of\nthat nested document. `--format text` prints just `content`.\n`--content-format` is what shows up inside that `content` field.\n\n## Decision tree\n\n```text\nWho consumes the output?\n\u251c\u2500\u2500 LLM (Claude, GPT, Gemini, local) \u2014 embed\/prompt context\n\u2502       --format text --content-format markdown\n\u251c\u2500\u2500 Vector store \/ RAG indexer\n\u2502       --format json --content-format markdown\n\u2502       (markdown preserves structure for chunking)\n\u251c\u2500\u2500 Downstream parser that expects machine-readable JSON\n\u2502       --format json --content-format plain\n\u2502       (cleanest text + structured metadata)\n\u251c\u2500\u2500 Human review \/ archival\n\u2502       --format text --content-format markdown\n\u251c\u2500\u2500 HTML re-rendering \/ web display\n\u2502       --format json --content-format html\n\u251c\u2500\u2500 Lossless intermediate for pandoc \/ academic tooling\n\u2502       --format json --content-format djot\n\u2514\u2500\u2500 Token-budget-constrained pipeline\n        --format text --content-format plain\n        (drops markup; add --token-reduction moderate for further savings)\n```\n\n## Examples\n\nFeed a PDF directly into an LLM:\n\n```bash\nxberg extract paper.pdf --content-format markdown\n```\n\nIndex a corpus into a RAG store with tables and headings preserved:\n\n```bash\nxberg batch docs\/*.pdf --format json --content-format markdown \\\n  | jq -c '.result | {content: .content, tables: .tables}'\n```\n\nStrip a file to bare text for a token-tight summarizer:\n\n```bash\nxberg extract long.pdf \\\n  --content-format plain \\\n  --token-reduction moderate\n```\n\nPull metadata only, ignore content:\n\n```bash\nxberg extract file.pdf --format json | jq '.result.metadata'\n```\n\n## When in doubt\n\n- **Default to `markdown`** as the content format. It is the best\n  compromise across LLMs, RAG, and human review, and Xberg has the\n  most faithful renderer for it.\n- Reach for `plain` only when downstream cannot tolerate any markup.\n- Reach for `djot` only if you're already in a djot\/pandoc pipeline.\n- Reach for `html` only when re-rendering for the web.\n- Reach for `json` for a heading-driven content tree, or `doctags` for Docling-compatible output.\n\n## Token-reduction (orthogonal)\n\n`--token-reduction` collapses whitespace, strips repeated headers\/footers,\nand trims boilerplate. It composes with any `--content-format`:\n\n- `off` (default), `light`, `moderate`, `aggressive`, `maximum`.\n\nUse `moderate` as a safe starting point for LLM context windows. `maximum`\nis lossy \u2014 verify before relying on it.\n\nSee `..\/..\/references\/cli-reference.md` for the full flag set and\n`..\/..\/references\/configuration.md` for the equivalent `output_format` and\n`token_reduction` keys in `xberg.toml`.\n","use_cases":["Feed a PDF directly into an LLM for context embedding","Index a corpus into a RAG store with tables and headings preserved","Strip a file to bare text for a token-tight summarizer","Pull metadata only, ignore content for archival"],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/xberg-io\/xberg\/blob\/ffbf7971796a126fc52f6bb8fb40418772071f61\/plugin\/.ai-rulez\/skills\/xberg-picking-a-format\/SKILL.md","source_commit":"ffbf7971796a126fc52f6bb8fb40418772071f61","license":null,"version":null,"listing_approved_at":"2026-11-16","created_at":"2026-11-15T14:15:31.000000Z","updated_at":"2026-11-16T05:16:54.000000Z","seo_title":"Choosing the Right Output Format for Document Extraction","seo_description":"Select the best format for extracted documents based on the downstream consumer (LLM, parser, archive) to ensure compatibility and efficiency.","seo_keywords":["document extraction format","LLM compatible format","RAG index format","token-efficient format","metadata extraction format"]}}