$str = "<h2>Title</h2>"; sanitize_text_field( $str ); // it will return "title" without any HTML tags!