🔥 Just Launched! Werra Premium Template for HyväSee it in Action

How to add WYSIWYG Editor in Magento 2 System Configuration

By Sanjay JethvaUpdated on May 22, 2025 1 min read

WYSIWYG is an HTML editor for easy content editing. WYSIWYG enables adding and formatting the content providing “What You See Is What You Get ” view. Preview the end result in the editing phase itself and thus avoid handling HTML tags! Interesting, isn’t it? 

However, the default Magento 2 does not offer WYSIWYG editor in the system configuration. Admin may want to display messages in a certain manner in frontend. The WYSIWYG editor makes the task simpler.

To overcome the default Magento 2 limitation, implement the below method to add WYSIWYG editor in Magento 2 system configuration.

Method to Add WYSIWYG Editor in Magento 2 System Configuration:

  • Add below code in the system.xml file
<field id="description" translate="label comment" type="editor" sortOrder="20" showInDefault="1"
                       showInWebsite="1" showInStore="1">
    <label>Description </label>
    <frontend_model>Vendor\Extension\Block\Adminhtml\Editor</frontend_model>
</field>
  • Create new file Editor.php at Vendor\Extension\Block\Adminhtml folder
<?php

namespace Vendor\Extension\Block\Adminhtml;

use Magento\Backend\Block\Template\Context;
use Magento\Cms\Model\Wysiwyg\Config as WysiwygConfig;

class Editor extends \Magento\Config\Block\System\Config\Form\Field
{
    public function __construct(
        Context $context,
        WysiwygConfig $wysiwygConfig,
        array $data = []
    )
    {
        $this->_wysiwygConfig = $wysiwygConfig;
        parent::__construct($context, $data);
    }

    protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
    {
        $element->setWysiwyg(true);
        $element->setConfig($this->_wysiwygConfig->getConfig($element));
        return parent::_getElementHtml($element);
    }
}

That’s all about WYSIWYG editor in system configuration for Magento 2!

Once you implement this solution, please refer our blog Add WYSIWYG Editor in Magento 2 System Configuration

Thank you.

Sanjay Jethva Full Image
Article bySanjay Jethva

Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe. His passion for Magento 2 and Shopify solutions has made him a trusted source for businesses seeking to optimize their online stores. He loves sharing technical solutions related to Magento 2 & Shopify.