update node field Programmatically
Here is how to update body field :

$nodes = Node::loadMultiple();
foreach($nodes as $node){
  $html = $node-&gt;body-&gt;value;
  $html = str_replace('blue','red',$html);  
  $node-&gt;set('body', [
          'summary' =&gt; 'the summary',
          'value' =&gt; $html,
          'format' =&gt; 'full_html', // probably, 
          /**
           * Correspond with format you need in admin/config/content/formats
           */
   ]);
   $node-&gt;save();
}