Markdown in Apex?

Has anyone built a Markdown parser in Apex? Looking to do something like this:

String raw = 'This is a *Markdown* string.  Large, multiline, has links & headings';
Markdown mdParser = new Markdown();
String parsed = mdParser.parse(raw);

// ==> 'This is a <em>Markdown</em> string.  Large, multiline, has links & headings'


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

I would recommend using an API to parse your markdown and return back html. One service I found that looks like it would work is from Github:

Method 2

No, there’s not currently any markdown support in apex, although it’s conceivably possible to write one with enough effort.

As Daniel Hoechst suggested making a callout to an external markdown rendering service is very likely the easiest and fastest way of handling this.

On top of that it’s very likely that any custom markdown rendering engine would have some compatibility bugs or security holes (depending on markdown flavor you can include raw HTML) unless you build an utterly amazing test suite.

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x