How to alter page content? Simple thing. I have some page (node). At end it produces some content, i.e.

&lt;h1&gt;This is original content&lt;/h1&gt;


I want to alter it with different content, i.e.

&lt;h1&gt;This is changed content&lt;/h1&gt;


So I need a way to collect original content, parse it, replace some part of it and put it back.

hook_ENTITY_TYPE_view() should be the way to do that:

https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Entity%21entity.api.php/function/hook_ENTITY_TYPE_view/8.2.x

And I tried example from that page (by Devendra Mishra) and it works, but it's adding additional content. I need a way to access original content and change it, not to just add new one.

To be clear, I don't want to change content on field level, but want to change final content, with all fields combined, ready to be rendered.
If you don't want to change the variables on field level you can parse the content in a #post_render callback after it is rendered:

/**
 * Implements hook_ENTITY_TYPE_view().
 */
function mymodule_node_view(array &amp;$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) { 
  $build['#post_render'][] = function ($html, array $elements) {
    return str_replace('original', 'changed', $html);
  };
}