/tag Command
Adds, removes, or lists scoreboard tags on entities. Tags can then be used in target selectors with the tag= argument to filter entities.
Syntax
tag <targets> add|remove <name>
tag <targets> listPermission: 2 (gamemaster / cheats enabled)Edition: Both
Examples
/tag @p add boss/tag @e[type=minecraft:zombie] add hostile/tag @s remove spectator/tag @e listNotes
Tag names in Java Edition are restricted to the characters A-Z, a-z, 0-9, -, +, ., and _. An entity may hold up to 1024 tags. Tags are not preserved across dimension changes unless explicitly re-applied.