Suppose I have a text format like full_html and I have an enabled filter with ID my_filter_id.

How can I disable the filter programmatically from full_html.

I needed to put this in an update hook.

Hopefully its a one-liner.

1 Answer 1


I did find a solution thought it wasn't a one liner. This will remove the filter from all text formats.

use Drupal\filter\Entity\FilterFormat;

function MYMODULE_update_10000(&$sandbox) {
  $filters = filter_formats();
  foreach ($filters as $name => $filter) {

    /* @var $filter Drupal\filter\Entity\FilterFormat */
    // Instantiate the filter collection prior to removing the filters to
    // avoid fatal errors.


I found the solution from Drupal.org

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.