Laravel convert markdown (md) to html

Laravel convert markdown (md) to html

Published at - Aug 26, 2021

Parsedown for Laravel

Build Status

This package is a Laravel wrapper around Parsedown. If you want to know more about Parsedown alone check out our base repository.


  • Blade Directive
  • Configuration File
  • Helper Function


Parsedown for Laravel is available as a Composer package. You can install it using the command below:

composer require parsedown/laravel


If you're using Laravel +5.5 you don't need to follow the steps below. The package auto-discovery feature has been implemented and will take care of loading the service provider for you.

But if that's not your case you will need to add the service provider to your config/app.php file:

return [
    // Other configurations above...

    'providers' => [
        // Other providers above...
        // Other providers below...

    // Other configurations below...

This package uses the Parsedown\Providers\ParsedownServiceProvider service provider to create a singleton of Parsedown. That's stored it in a container called parsedown. It uses the following options to set the default behavior for that instance:

Name Description Default
breaks_enabled Converts line breaks such as \n into <br /> tags. false
inline Enables inline parsing for the parsedown() helper and the @parsedown directive by default. false
markup_escaped Escapes HTML in trusted input. Redundant if safe_mode is enabled. false
safe_mode Doesn't process untrusted user-input. true
urls_linked Automatically converts URLs into anchor tags. true

You can overwrite these values by publishing the config/parsedown.php file with the following command:

php artisan vendor:publish --provider="Parsedown\Providers\ParsedownServiceProvider"


The snippets below show how you can easily use Parsedown in your *.blade.php files:

@parsedown('Hello _Parsedown_!')

...or (using the helper approach)

{{ parsedown('Hello _Parsedown_!') }}

Any of the code above will generate:

<p>Hello <em>Parsedown</em>!</p>

If you want to parse a value using the inline style you just need to set the second argument as true:

@parsedown('Hello _Parsedown_!', true)

...or (using the helper approach)

{{ parsedown('Hello _Parsedown_!', true) }}

Any of the code above will generate:

Hello <em>Parsedown</em>!

The helper is globally available and can also be used with PHP code throughout your project.

Lumen Support

Laravel and Lumen pretty much share the same core code. The instructions below should be enough to set this package for your Lumen project.

Enable Facades in Your Project

Ensure you have the following in your bootstrap/app.php file:


Service Provider Registering

As Lumen does not support package auto-discovery you got to do it manually adding the code below in your bootstrap/app.php file:


Github Url

About author

Harendra Kanojiya

Hello, I am Harendra Kumar Kanojiya - Owner of this website and a Fullstack web developer. I have expertise in full-stack web development using Angular, PHP, Node JS, Python, Laravel, Codeigniter and, Other web technologies. I also love to write blogs on the latest web technology to keep me and others updated. Thank you for reading the articles.

Related Posts -

Laravel backup &#8211; A modern backup solution for Laravel apps
Laravel backup &#8211; A mo ...

This Laravel package creates a backup of your application. The backup ...

Laravel - convert pdf to image
Laravel - convert pdf to im ...

Convert a pdf to an image This package provides an easy to work with the c...

Selenium for Laravel
Selenium for Laravel ...

Table of Contents Key Points:Requirements:Installation guide:Create fir...

A mail driver to quickly preview mail
A mail driver to quickly pr ...

Table of Contents InstallationConfiguring the mail transportRegisterin...

Laravel real-time chat application
Laravel real-time chat appl ...

Laravel Realtime ChatBuild Status Code Climate A realtime chat sample w...

Follow Us

Follow us on facebook Click Here

Facebook QR
Scan from mobile
Join our telegram channel Click Here
Telegram QR
Scan from mobile