I am looking for an open source Markdown parsing library for .NET/Mono (i.e. usable from C# code) (preferably with MIT/BSD license or similar).

I have found various such libraries, but the one issue with all of them is that they all convert the information gathered from Markdown text to a fixed output format, usually HTML.

I am looking for a Markdown parser that does (at least) one of the following:

  • fire events for the components of Markdown text (like SAX parsers do for XML)
  • let me pull the text components (like XmlReader does for XML)
  • build a data structure (like what DOM would be for XML) that represents the contents of the Markdown text for further programmatical processing

I am looking to achieve this in a non-hacky way, that is, solutions that let the Markdown source be converted to HTML, just to do something with that HTML and convert it back to Markdown-something afterwards, do not sound maintainable enough.

  • Couldn't you just use an HTML parser to parse the HTML string into DOM?
    – svick
    Aug 21, 2016 at 1:47
  • @svick: Sorry, I'm not looking for a hacky solution. Added that requirement to the question. I have just found a workable solution, as well, though.
    – F-H
    Aug 21, 2016 at 18:07
  • Wait, convert back to Markdown? You didn't mention that before.
    – svick
    Aug 21, 2016 at 18:57
  • @svick: Each of the three options I suggest describe a way of directly getting the Markdown contents. If one first converts the Markdown source to HTML, one has to go back from HTML to get the (simpler) Markdown contents. Granted, maybe it is more or less a 1:1 mapping between HTML and Markdown (although, as far as I've seen, most Markdown parsers don't really make any guarantees about what the generated HTML source looks like, so I cannot rely on that), but it still feels "wrong" to go from Markdown to HTML if I actually want one of the intermediate steps on that route.
    – F-H
    Aug 21, 2016 at 21:08

1 Answer 1


I have meanwhile found CommonMark.NET.

It seems to do what I am looking for, in particular, it fulfils the third option I suggested in my question, by giving me access to the parsed AST (abstract syntax tree).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.