You use who when referring to the subject of a sentence or clause—the person performing the action. Use whom when referring to the object of a verb or preposition—the person receiving the action.
How to decide between who and whom:
- If you can replace the word with he or she (subject pronouns), use who.
- If you can replace it with him or her (object pronouns), use whom.
For example:
- Who is coming to the party? (He is coming.)
- Whom did you invite? (I invited him.)
Additional points:
- Whom is used after prepositions, especially in formal contexts:
- To whom was the letter addressed?
- With whom are you going to the event?
- In everyday conversation, whom is often replaced by who , but using whom correctly is important in formal writing.
- When whom introduces a relative clause and is the object within that clause, it is also correct:
- The person whom I met yesterday is here.
In summary, use who for subjects and whom for objects, especially after prepositions or in formal writing. The "he/him" substitution test is a reliable way to remember this rule.