Rendering Markdown in Ruby on Rails is a way to display formatted text within a web application. Markdown is a lightweight markup language that allows users to write in a simple, easy-to-read format and then convert it to HTML for display on the web.

In Ruby on Rails, there are several libraries available for rendering Markdown, including the popular Redcarpet gem. To use Redcarpet, you first need to add it to your Gemfile and run bundle install. Then, you can create a helper method in your application to convert Markdown to HTML. For example:

module ApplicationHelper
  def markdown(text)
    options = {
      filter_html: true,
      hard_wrap: true,
      link_attributes: { rel: 'nofollow', target: "_blank" },
      space_after_headers: true,
      fenced_code_blocks: true

    renderer =
    markdown =, extensions = {})


In this example, the markdown method takes in a string of text in Markdown format and uses the Redcarpet gem to convert it to HTML. The options passed in customize the behavior of the renderer, such as automatically adding the “nofollow” attribute to all links and converting code blocks to use the “fenced code blocks” syntax. The html_safe method is called to ensure that the HTML output is safe to display on the page.

Once this helper method is defined, you can use it in your views to display Markdown-formatted text. For example:

<%= markdown("# This is a heading") %>

This will output the following HTML:

<h1>This is a heading</h1>

Another popular gem is CommonMarker, which is a C implementation of CommonMark, a strongly defined, highly compatible specification of Markdown. CommonMarker is generally faster than other Markdown parsers written in pure Ruby.

In addition to these libraries, there are also other libraries like Kramdown, RDiscount, BlueCloth, etc.

In summary, rendering Markdown in Ruby on Rails is a simple process that can be accomplished with the use of a Markdown library such as Redcarpet or CommonMarker. These libraries provide a convenient way to convert Markdown text to HTML for display on a web page, and can be easily integrated into a Rails application with the use of a helper method.