render form item of type text_format in twig file I have created a form element, basically I want text formats to change texts as accordingly.

$form['thankyou'] = [
        '#type' =&gt; 'text_format',
        '#title' =&gt; $this-&gt;t('Thank you'),
        '#format'=&gt; 'full_html',
        '#default_value' =&gt; $config-&gt;get('thankyou'),
      ];


Now, I have created a function, where I'm getting this form element value.

$config = \Drupal::configFactory()-&gt;getEditable('myconfig');
 $thankyou_paid = $config-&gt;get('thankyou');


If I directly debug $thankyou_paid, I get all my data formatted. (in bold)

But If I render it through hook_theme,

return array(
      '#theme' =&gt; 'mytwig',
      '#type' =&gt; 'markup',
      '#thankyou' =&gt; $thankyou_paid,
      '#cache' =&gt; ['max-age' =&gt; 0,],
    );


It gives me &lt;b&gt;ugwdegfgiurgiuterug&lt;/b&gt;. Means, data gets rendered without formatting. 

How to get this text (ugwdegfgiurgiuterug) as ugwdegfgiurgiuterug.
It's unsafe to use the raw filter, better use the render element 


  raw
  
  This filter should be avoided whenever possible, particularly if you're outputting data that could be user-entered. See this page
  for more information on auto-escape in Drupal 8.


processed_text:

return [
  '#theme' =&gt; 'mytwig',
  '#thankyou' =&gt; [
    '#type' =&gt; 'processed_text',
    '#text' =&gt; $thankyou_paid,
    '#format' =&gt; 'full_html',
  ],
];


To configure the text format visit /admin/config/content/formats and read the warnings


  Improper text format configuration is a security risk.


In this case it might be better to use Restricted HTML or Basic HTML.