How to Convert Word to Markdown using C#

In this short tutorial, we will learn how to convert Word to Markdown using C#. Markdown format is helpful for presenting information over the web, as compared to the Word files in DOC or DOCX format. So you can easily convert DOCX to Markdown using C# with the following steps and code snippet in any operating system like Linux, macOS or Windows.

Steps to Convert Word to MD file using C#

  1. Install Aspose.Words library from NuGet package manager tool in Visual Studio.
  2. Initialize an instance of the Document class to load input Word file
  3. Set different properties for output markdown with MarkdownSaveOptions class
  4. Save the output markdown file

In the steps above, the source Word file is loaded and then you can specify different properties of output markdown file like page header footer, memory optimization, encoding, etc. Finally, the output file is created in the process of converting DOCX to Markdown using C#.

Code to Convert DOCX to MD using C#

In this sample code, an object of Document class is first initiated to load the source Word file. Several properties are then set for customizing the rendering process and the attributes of output MD file. Finally, you will be able to convert Word DOC to Markdown in C# in your project with simple API calls.

In this article, we have explored how to convert Word to MD file using C#. However, if you want to convert a DOCX file to HTML, refer to the article on how to convert DOCX to HTML using C#.

 English