Word to Markdown for an AI Knowledge Base

Vladimir Lomtev•
Word to Markdown for an AI Knowledge Base

To convert Word to Markdown for an AI knowledge base, prepare heading styles in the DOCX, agree on revisions, run a Pandoc conversion with image extraction, and check the meaning of tables. The output should be a portable package: a text file .md, linked images, and details about the source document. After that, you can configure search and content-based answers.

Instructions for owners of corporate policies and specialists preparing documents for RAG—retrieval of relevant passages for a language model's answer. This covers one digital DOCX: scans, batch processing, and search configuration need to be addressed separately.

Prepared by Vladimir Lomtev's AI studio. The documentation was reviewed on November 14, 2026. The commands below are the documented procedure with suggested examples; the editorial team did not run them on DOCX and did not measure AI answer quality. The studio provides data preparation and enterprise knowledge base implementation services; no affiliate links are used in this material.

Contents

What to prepare before conversion

Take a copy of the approved document, for example a returns policy. Keep the original in the system where its versions and approvals are managed. Create a separate folder for the work and place the copy there under the name source.docx; run the commands from this folder.

Markdown is a text format with markers for headings, lists, and links. Pandoc is a converter between document formats. It works well when the useful content is already in Word paragraphs, headings, and tables. The developers warn that conversion preserves structure with possible losses, and complex layouts and tables may not transfer completely. So the .md extension by itself does not mean the file is ready to upload into AI. .md . Source: Pandoc documentation.

Define the target system before choosing the output format. If it explicitly supports GitHub Flavored Markdown, use gfm. If the loader documentation requires Pandoc Markdown, choose markdown. For a system that accepts plain text only, first decide where headings, tables, and images will go: the converter does not define loader behavior.

Source material Action before launch Expected result
A digital policy with standard paragraphs Prepare styles and approve the revision You can move on to conversion
DOCX with page photos instead of text Separate out the OCR task There is separate recognized text for review
A policy with diagrams and complex tables Define how to describe their meaning in words You know which elements require manual handling
A legally significant original Preserve the original and its identifying details Markdown is used as a derivative copy

For a paper source, it is better to start with digitizing the archive for AI searchrather than trying to fix it with this command.

Step 1. Make headings part of the Word structure

Open the DOCX copy. Select the titles of the main sections and apply the “Heading 1” style; for subsections, use “Heading 2.” In Word, this is done through “Home” → “Styles.” A larger font and bold formatting by themselves do not replace a heading style. Microsoft: adding a heading.

Then, in Word for Windows, open the Navigation Pane and see whether the needed sections appear. Microsoft links the appearance of body headings in this pane to applied styles; Word for Mac and the web version behave differently. This is a useful preliminary structure check, though it does not prove that the future conversion will be correct. Microsoft: Navigation Pane.

In the proposed policy, the “Product Return” section should be the parent of the “Conditions” and “Process” subsections. If all three titles are at the same level, search will later get less precise context. First fix the hierarchy in the source copy: redoing it by hand only in Markdown will drift from the next version of Word.

Step result: the section list in the Navigation Pane matches the document's logical outline. Do not turn every highlighted line, column heading, or warning into a heading: the level is needed to organize sections.

Step 2. Decide which text revision to carry over

Ask the policy owner to confirm the current terms. Pay especially close attention to changes in amounts, deadlines, exceptions, and negations. Converting a document with unresolved edits can produce text that is technically readable but operationally incorrect.

Pandoc has the parameter --track-changes=accept|reject|all. The accept mode applies insertions and deletions, reject discards changes; both ignore comments. The all mode preserves changes and comments with markup. The main command below explicitly uses accept; this is a decision about how the text is represented, not confirmation that the document owner approved it. Pandoc: handling changes.

If a comment contains the only explanation for an exception, move the agreed rule into the main text of the source copy. Do not expect it to make it into the knowledge base together with the discussion. If you need to analyze the revision history, keep it as a separate material with a clear purpose and access controls: such an archive should not be mixed with active employee instructions.

Step result: the owner has confirmed the revision, and all rules the AI should answer about are in the main content. Disputed versions remain outside the published package.

Step 3. Install Pandoc and run one conversion

Install Pandoc according to the official instructions for your OS. Open the terminal again and check the version:

pandoc --version

A successful sign is the terminal printing the Pandoc version. If the command is not found, check the installation and make sure the program is available through PATH. This operation does not require a language model API key or a connection to cloud AI.

From the folder with source.docx run this single line:

pandoc source.docx --from=docx --to=gfm --track-changes=accept --extract-media=assets --wrap=none --output=knowledge.md

Here, --from and --to define the formats, --output is the output file. The --extract-media parameter extracts media and adjusts the links to them; --wrap=none disables automatic line wrapping in the source text. Do not run the command over your only edited copy of the result: use a clean working folder. Pandoc: parameters.

After it finishes, find knowledge.md; if there are extracted images, check the assets folder and the actual paths in the Markdown. No error means the command completed. You still need to verify that all rules were preserved in the next steps.

For a loader that specifically needs Pandoc Markdown, the suggested replacement is --to=markdown. Keep the other parameters the same and verify the output again. Do not choose a dialect based on which file looks nicer in the editor: what matters is the format the receiving system actually parses.

Step 4. Check tables as a set of rules

Match every important table in the DOCX and Markdown. Start with the column headers, then check that the values line up with the rows. Pay special attention to merged cells, units of measure, and conditions that apply to several rows at once.

GFM supports tables with a header row and a separator row; inline formatting is allowed in cells, but not block elements. A complex Word structure cannot be treated as portable just because the editor shows a similar grid. GFM specification: tables.

An example of simplification: the source table contains the category "Good-quality product," with several rows under it that have different conditions. In the derived copy, repeat the category in each row or turn each variant into a separate rule. Choose the representation together with the policy owner; do not add conditions on your own.

For a complex exception, you can use this format:

Category: [value from the source]
Condition: [full condition text]
Employee action: [action from the policy]
Exception: [exception, if present in the source]

This is a suggested template that needs to be filled in with real content. For example, the line "Term — 14 days" without stating what starts the countdown is not enough for an answer. Go back to the source and keep the wording intact. The number here illustrates a context problem and is not a legal rule.

Step result: each condition is linked to its category, action, and exception. If the meaning cannot be restored confidently, leave the item for manual handling before upload.

Step 5. Transfer the meaning of images and check links

Open the images referenced by knowledge.md. Compare them with the source: an approval flowchart, a form screenshot, and a decorative banner require different approaches. The fact that a file was extracted does not mean AI search will read its contents.

For a process diagram, add a matching text description nearby: where the branch starts, which condition selects the next step, and how it ends. For a form screenshot, identify the important fields and the user's action. A decorative image can be excluded from the derived set if it does not contain rules and the document owner agrees.

Keep relative image links together with the folder they point to. Then test portability: copy the entire set to another folder and open the Markdown in the viewer you use. An image that only appears via an absolute path on the author's computer cannot be considered a portable asset.

Also check hyperlinks to other policies. If the wording "see the section above" has lost a clear target, replace it in the derived copy with the exact section title while preserving the meaning. For important links, open the target document under the account of the future reader; conversion does not carry access permissions between systems.

Step result: the semantic image has a text equivalent or a separate handling assignment, and the required links are available in the target context. Check image support in the loader itself in its documentation and interface.

Step 6. Deliver the package to the knowledge base

Save a provenance card alongside the result. This is a suggested text template for the working set; the method for passing metadata depends on the receiving system.

Document title:
ID in the source system:
Version or revision date:
Link to original:
Content owner:
Allowed audience:
Conversion date:
Pandoc version:
Decision on edits:
Known losses and manual fixes:

Do not include empty fields in search text. It is better to pass the ID and version as metadata if the loader supports it. Set the allowed audience using the access controls of the base itself: a note that says "sales department only" in the text does not restrict retrieval.

Upload one document first. See which headings and fragments the system picked up, and find a specific rule from the table. Then ask a question about an exception and open the source of the answer. Success for this step means you can trace the answer back to the needed fragment of the current version. If the loader dropped a table or an image, fix the representation or the upload method before processing the rest of the files.

Splitting text into chunks is the next stage. Its parameters are covered in the document chunking instructions for RAG. Readable Markdown helps you see the structure, but you still need to test search and answer quality in your own system.

Common errors and fixes

Symptom Possible cause What to do
Section names became ordinary lines Headings were formatted with font only Apply styles in the DOCX and run the conversion again
The explanation from the comment disappeared A mode was selected that ignores comments Move the agreed rule into the main text
The table looks fine, but the answer mixes up categories The condition lost its connection to the row Repeat the context or break the table into rules
The image is in the folder, but the AI does not use it The loader does not process images Add an agreed description or a separate processing path
After copying the package, the images disappeared Paths and file locations no longer match Check the links in the Markdown and move the needed folder
An old rule keeps showing up in answers A different revision or cache remains in the base Check the answer sources and the base update order

These are diagnostic hypotheses, not results from testing your document. If the problem is tied to updating an already active base, you will need a separate version-replacement process; reconverting the Word file does not do that.

How the studio helps prepare policies for AI

AI studio by Vladimir Lomtev focuses on data preparation and corporate knowledge bases with RAG. For policies and procedures, the task may include three steps: converting the document structure into a format suitable for upload; linking the materials to versions and source documents; and integrating search into the company workflow with subsequent review.

The first step is to choose one policy or procedure, show its current usage flow, source, access restrictions, and the criterion for a useful answer. This will help determine whether simple conversion is enough or whether tables and diagrams will need additional processing. Discuss the project.

Bottom line: start with one approved DOCX

Converting Word to Markdown for AI starts with the current version and structure of the document. After running Pandoc, check the tables, the meaning of the images, and file portability, then upload one set and trace the answer back to the source rule. Move on to processing the folder of policies and procedures only after the path of each important element from Word to the answer in your knowledge base is clear.

Request an audit

Share your contact details and we will follow up.

← All articles

Comments (0)

Loading comments…

Leave a comment
No registration required

Book a strategy call
for agentic operations

Tell us which workflow you want to improve. We will map feasibility, risks, and the fastest MVP path.

By submitting, you agree to our privacy policy

Contacts

Global Operations

Serving U.S. clients remotely
with private cloud and on-prem options

Strategy calls by request

We respond after reviewing your workflow context.

info@agentsunrise.pro

For partnership inquiries

Have a proposal?

Write to us in messengers

© 2026 AgentSunrise