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'
  • 1
    I wonder if it might be better to use an API to do it for you rather than try to recreate everything in Apex. See developer.github.com/v3/markdown Commented Mar 20, 2014 at 16:17
  • 3
    I really wish Chatter could accept markdown formatting so code could be shared more easily.
    – greenstork
    Commented Mar 20, 2014 at 16:47
  • An API could be one approach - or using a client-side javascript library. With the API approach, I'd want to reduce call-outs by caching the processed version in a second long text area field, which is probably a best practice, anyway...
    – Benj
    Commented Mar 21, 2014 at 18:19
  • @DanielHoechst want to make your API suggestion an actual answer?
    – Benj
    Commented Mar 21, 2014 at 18:21
  • Did using client-side JavaScript not fit with where you needed the processing done? Seems like a good place to do the job if say you are just using Visualforce to present the HTML of a text area that contains markdown.
    – Keith C
    Commented Mar 22, 2014 at 9:43

3 Answers 3


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: https://developer.github.com/v3/markdown/.


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.

  • 3
    Makes sense. If only we could import Java libraries into Apex...
    – Benj
    Commented Mar 21, 2014 at 18:20

While I was looking for the same thing I ran into this Github project: https://github.com/nilvon9wo/ApexMarkdownCompiler

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .