This confuses lots of people, but it doesn’t have to. Here’s the simple way to tell who and whom apart:
Who is the person taking action (the subject of the sentence):
Who put Addy’s pacifier in the freezer? Nhung did.
Nhung took action. (She put Addy’s pacifier in the freezer.) “Who” indicates that we don’t know which person took action, but that we know somebody did.
Whom is the person being acted upon (the object of the sentence):
Whom should we invite to our party?
In this case, “we” is the subject – “we” are taking action (inviting people to our party). “Whom” refers to the people that we are about to act upon (by inviting them).
Whom can also be the object of a preposition:
To whom did you give your collection of pogs?
For whom did you buy these pogs?
The key is recognizing that “whom” is still being acted upon. (I gave my collection of pogs to Addy. I bought these pogs for David.)
That’s it! If you’re uncertain about whether to use “who” or “whom,” ask yourself: is this person doing stuff or having stuff done to them? (This rule even applies to those extra-confusing cases involving verbs within dependent clauses. If you're curious, check out Rule 1 here.)
Whoever vs. Whomever
The same principle applies to “whoever” and “whomever”:
Whoever said that is out of his mind.
“Whoever” refers to some unnamed person who took action – in this case, by saying something. On the other hand,
I think Khabib will beat Conor, and I’ll say it to whomever I like.
"Whomever” is the object of a preposition here. I’m saying stuff to “whomever,” so “whomever” is being acted upon. Same as above!