How to Change Name Color in Minecraft (Teams Command)
Minecraft Java Edition 1.21+ and 26+ – Change Player or Mob Name Color
Want to make your name colored in Minecraft or change the name color of mobs?
In this tutorial you will learn how to use the /team command to create a team, choose a color, and add players or entities to it.
This method works in Minecraft Java Edition 1.21+ and 26+ and is widely used for maps, servers, minigames, and rank systems.
Use this command to create a team and choose any name you want. I chose name
team add name
Choose a color and use the command below. I chose red
team modify name color red
Now, let's join this team
team join name @p
To add other player, the command is similar to the last one, just replace @p with the player or mob
I will test it with a pig. Here is the command to summon a mob with its name visible
summon minecraft:pig ~ ~1 ~ {CustomNameVisible:1b}
Or you can rename an existing mob and make its name visible like this
data merge entity @e[type=minecraft:pig,limit=1,sort=nearest] {CustomName:"Custom Pig",CustomNameVisible:1b}
And lastly, add the mob to the team
team join name @e[type=pig,limit=1]