Developers: convert a folder to Markdown for RAG
Turn a folder of Office files into clean Markdown or JSON for a search or language model pipeline.
Convert a folder
fetlar docs/ -o out/ --normalize llmEvery Word, Excel and PowerPoint file directly in docs/ becomes a Markdown file in out/. Files are converted in parallel, largest first. One bad file does not stop the others.
out/budget-v1.md
out/contract-v1.md
out/supply-ar.md--normalize llm removes Arabic diacritics, tatweel and invisible characters. The text stays readable and the structure does not change.
Use the exit code
fetlar docs/ -o out/ || echo "some files failed, see stderr"Each failure is on stderr with the file's path. The exit code is the code of the first failed input. See Exit codes.
Chunk by structure
JSON gives typed blocks with heading levels, so you can split on headings:
fetlar contract-v1.docx -t json --compact{"kind":"docx","pages":[{"page":1,"title":null,"blocks":[{"type":"heading","text":"Supply agreement","rtl":false,"level":1,"page":1},{"type":"heading","text":"4.2 Payment terms","rtl":false,"level":2,"page":1}]}]}(Shortened.) See JSON output schema.
For Excel, each sheet is a page. Use --max-cells to cap very large workbooks.
Subfolders and other formats
A folder is not searched recursively. Use find and name the files:
find . -name '*.docx' -print0 | xargs -0 fetlar -t text -o out/CSV, TSV and HTML files must be named on the command line.
Slides
PowerPoint speaker notes are included by default. Use --no-notes to leave them out and --slide-numbers to include slide numbers.