The Stunned condition seems to be incredibly powerful.
Are there any ways to end it with magic, magic items, abilities, or prevent it from occurring in the first place?
Role-playing Games Stack Exchange is a question and answer site for gamemasters and players of tabletop, paper-and-pencil role-playing games. It only takes a minute to sign up.Sign up to join this community
There is at least one spell that can remove the stunned condition: power word heal. It is 9th level, however.
I couldn't find any spell, class feature, or monster ability that could inflict the stunned condition automatically. All of them only apply the condition if an initial saving throw is failed. Anything that improves or gives advantage to those saving throws will thus help prevent the stun from occurring.
Aura of purity is such a spell; it doesn't remove the stunned condition, but does bestow advantage on saves against it.
Some stun effects, like the Monk's stunning strike, an otyugh's tentacle slam attack, an allip's howling babble, or a siren's stupefying touch, don't end on a save; they just end on the next turn.
The stun effect of the divine word spell is the same, except it lasts for an hour(!) with no chance of ending it early if the initial save is failed.
It can be used to transform into a creature that is immune to the stunned condition.
This naturally helps prevent stuns from being applied but it is debatable if it works to remove the condition from an already stunned creature.
You can easily find a list of available creatures meeting this criteria in this dnd-beyond search
Two big categories that I would consider as well:
Way of Mercy Monk
Path of the Juggernaut Barbarian
Outer Essence Shard (Lawful)
The Symbol (PHB) spell, when casting the 'Stunning' option:
Each target must make a Wisdom saving throw and becomes stunned for 1 minute on a failed save.
The Contagion (PHB) spell, when casting the 'Slimy Doom' option:
In addition, whenever the creature takes damage, it is stunned until the end of its next turn.
Since in these cases the Stunned condition is a spell effect from a spell with a non-instantaneous duration, it can be ended by a dispel magic or an ability that ends spells or spell effects, such as the Paladin's Cleansing Touch, if cast before the spell has expired.
Other spells that cause the Stunned condition have instantaneous durations, including
The Divine Word (PHB) spell:
30 hit points or fewer: blinded, deafened, and stunned for 1 hour
The Psychic Scream (XGtE p. 163) spell:
On a failed save, a target takes 14d6 psychic damage and is stunned.
The Power Word: Stun (PHB) spell:
If the target has 150 hit points or fewer, it is stunned.
The more traditional view in this case is that dispel magic and similar effects cannot end the stunned condition, because it is a magic effect that persists after the spell itself, and dispel magic ends only spells. A literal reading of the dispel magic spell, however unpopular it is on this stack, suggests that when dispel magic is upcast, it can end spell effects even if the spell itself had already ended. Note that for this to work with the 9th level spell psychic scream, however, you would need to find a way to cast dispel magic at 10th level.