Updated:
Java: set max health with /attribute
| Version | 20 hearts |
|---|---|
| Java 1.21.2+ | /attribute @s minecraft:max_health base set 40 |
| Java 1.16–1.21.1 | /attribute @s minecraft:generic.max_health base set 40 |
The number is health points; 2 is one heart. The default is 20 (10 hearts) and the maximum is 1024. Java 1.21.2 dropped the generic. prefix, which is why older commands fail.
Fill the new hearts
/effect give @s minecraft:instant_health 1 5 true
Raising max health leaves the extra hearts empty. Instant Health fills them at once; eating or waiting also works.
Reset or apply to everyone
/attribute @s minecraft:max_health base set 20
/attribute @a minecraft:max_health base set 40
The first line restores the default; the second gives everyone online 20 hearts. Players who join later are not affected, so run it again after they join.
Health Boost (Java and Bedrock)
| Version | 10 extra hearts |
|---|---|
| Java | /effect give @s minecraft:health_boost infinite 4 true |
| Bedrock | /effect @s health_boost 99999 4 true |
Each level adds two hearts; amplifier 4 is level V, so 10 hearts. It is an effect, so milk and death remove it. Remove it with /effect clear @s minecraft:health_boost on Java or /effect @s clear on Bedrock.
Mobs
For mobs, set max health and current health together; see the attribute guide for a boss example.
On Java 1.21.2 and later, a zombie with 100 health (50 hearts) looks like this. Without Health:100f it spawns with only 20 health, even though the maximum is 100.
/summon zombie ~ ~ ~ {attributes:[{id:"minecraft:max_health",base:100}],Health:100f}
On 1.20.5 to 1.21.1, use minecraft:generic.max_health as the id. To change a mob that already exists, run /attribute on it and then /effect give it Instant Health, or simply summon a new one.
Show health on screen (Java)
Extra hearts past the first row can be hard to read. A scoreboard objective with the health criterion shows each player's exact health:
/scoreboard objectives add hp health "HP"
/scoreboard objectives setdisplay below_name hp
/scoreboard objectives setdisplay list hp
below_name shows the number under name tags (belowName before 1.20.2), and list shows it in the Tab player list. The value updates when health changes. Bedrock Edition has no health criterion, so this works on Java only.
Common questions
- Hearts are empty: only the maximum changed; use Instant Health.
- Fewer hearts: set a value below 20 for hardcore-style challenges.
- Error: match the name to your version; /attribute does not exist before 1.16.
Check your command
The Command Error Doctor checks common syntax mistakes in your browser.