how to remove all body classes in wordpress

I’m going to assume you mean the classes generated by body_class(), e.g. from the twentytwentyone header.php:

<body <?php body_class(); ?>>
<?php wp_body_open(); ?>

The simplest thing to do is to just remove the <?php body_class(); ?> call from your header.php. Or if you can’t / don’t want to change that, create a new header.php for these pages e.g. header-custom.php and load this with wp_head('custom') in your template.

Or if you really do need to suppress the output of body_class() then you can filter that away:

function empty_body_class($classes, $class) {
    return [];
}
add_filter( 'body_class', 'empty_body_class', 999, 2 );

but you’ll probably be left with an empty class="" on the body tag.


Or (as you’ve asked in comments) if you just want to remove anything starting “page”, or a fixed string “example_class”, you can just edit the array in the filter instead e.g.

function filter_body_classes( $classes, $class ) {
    foreach( $classes as $key => $value ) {
        if ( strpos( $value, 'page' ) === 0
             || $value === 'example_class' ) {
            unset( $classes[$key] );
        }
    }
    return $classes;
}
add_filter( 'body_class', 'filter_body_classes', 999, 2 );