Compare Markdown Documents

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Comparison MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-comparison -- dnx GroupDocs.Comparison.Mcp --yes
Folders, licensing and more →

GroupDocs.Comparison for Python via .NET compares Markdown documents and highlights differences in content, formatting, and structure. Useful for versioned documentation, README files, and technical writing where precise change detection is needed.

The API can:

  • Compare two or more Markdown (.md) files.
  • Highlight insertions, deletions, and modifications.
  • Export results to a single Markdown file or another supported format.

Example: Compare Markdown documents

from groupdocs.comparison import Comparer

def compare_markdown_documents():
    with Comparer("./source.md") as comparer:
        comparer.add("./target.md")
        comparer.compare("./result.md")

if __name__ == "__main__":
    compare_markdown_documents()

source.md is the source file used in this example. Click here to download it.

target.md is the target file used in this example. Click here to download it.

Markdown-specific notes

  • Extensions. GroupDocs.Comparison recognises .md, .mkd, .mdwn, .mdown, .markdown, .markdn, .mdtxt, and .mdtext as Markdown content. The output extension drives the result format — pass result.md for a merged Markdown file or result.html for a rendered HTML report.
  • Structure-aware comparison. Heading levels, list nesting, and code-block boundaries are preserved in the merged result so the output stays renderable.
  • Front matter. YAML / TOML front matter is treated as opaque text content. Changes inside the front matter block are reported the same way as body changes.