Pick the entities that swing with a selector or a player name. Multiple entities are allowed, so one command can animate a whole crowd.
/swing accepts any entity, but only models with an arm-swing animation show it: players and humanoid mobs like villagers, zombies and piglins read clearly, while armless mobs and armor stands show nothing.
No hand argument. The game swings the main hand, same as writing mainhand.
Plays one arm-swing animation for every matched entity. Purely visual: no damage, no block interaction. Needs permission level 2; works from 26.1 onward.
The swing is one quick animation per run. For believable mining or combat in a cutscene, loop the command from a repeating command block every few ticks and pair it with /playsound and /particle so the motion has sound and impact.
/swing is Java Edition's command for playing the arm-swing animation on demand, added in 26.1. It is the motion of an attack or a mining hit without any of the gameplay: no damage, no block breaking, no interaction. That makes it the cleanest way to animate NPCs and actors in adventure maps, where mobs need to look busy without actually fighting.
The command has one optional argument chain. /swing on its own swings the main hand of whatever runs the command, which makes it useful inside /execute as chains where each entity executes for itself. /swing <targets> animates any selection of entities, and an optional mainhand or offhand keyword picks the arm. All forms require permission level 2, so they run from an operator's chat, a command block or a datapack function.
One run plays one swing. The animation is broadcast to every player who can see the entity, exactly like a normal attack swing, so a whole server watches the same cutscene. Entities whose models have no arm-swing animation, such as armor stands and armless mobs, accept the command but show nothing; stick to players and humanoid mobs when the swing needs to be seen.
The command was added in 26.1 and the syntax has not changed since, so the same generated command works in every version from 26.1 to the current release.
Copy any of these as a starting point, or rebuild them in the generator above:
/swing @pThe nearest player swings their main hand once./swing @e[type=villager,distance=..10]Every villager within 10 blocks swings, an instant crowd reaction for a market scene./swing @e[type=zombie,limit=1,sort=nearest] mainhandThe nearest zombie swings its main hand, written out explicitly./swing @a offhandEvery online player swings their off hand, the shield arm./execute as @e[tag=actor] run swingThe bare form through /execute: each tagged actor becomes the executor and swings its own main hand.Before /swing, mapmakers faked arm animation by making mobs actually attack things, with all the damage and pathfinding problems that brings. Now a villager blacksmith can hammer at an anvil, a miner NPC can chip at a wall, and a battle in the background of a cutscene can rage forever without anyone losing a heart. Tag your actors, point one looped command at the tag, and the whole scene animates.
The swing itself is silent and effectless, which is a feature: you control the presentation. A convincing mining loop is /swing every 6 to 10 ticks, /playsound with a block-breaking sound on each swing, and /particle block at the wall being mined. A staged fight adds /damage at the moment a hit should land. Because each piece is a separate command, the timing is yours, which is exactly what cutscene work needs.
Two practical notes. First, the bare form inside /execute as @e[tag=actor] run swing and the targeted form /swing @e[tag=actor] do the same thing; the execute form matters when the swing is one step in a longer per-entity chain. Second, armor stands do not play swing animations, so build posed scenes with armor stands and moving scenes with living mobs.
The /swing command, added to Java Edition in 26.1, plays the arm-swing animation on entities: the same motion you see when a player attacks or mines. It is purely visual, dealing no damage and breaking no blocks. Run /swing on its own to swing the executor's main hand, /swing <targets> to animate any selection of entities, or add mainhand or offhand to pick the arm. It requires permission level 2, like other game-master commands.
Target the mob with a selector: /swing @e[type=zombie,limit=1,sort=nearest] makes the nearest zombie swing its main hand once. Any entity selector works and can match multiple entities at once, so /swing @e[type=villager,distance=..10] animates every villager within 10 blocks. Only models with an arm-swing animation visibly move, so use players and humanoid mobs like villagers, zombies, piglins and pillagers.
No. /swing only plays the animation; it does not run an attack, deal damage, trigger sweep attacks or interact with blocks. That makes it safe to spam in cutscenes. To fake a real hit, pair it with /damage for the health change, /playsound for the attack sound, and /particle for the impact effect.
The hand argument picks which arm animates. mainhand swings the main arm, the one that attacks and mines; offhand swings the off hand, the arm that holds shields, torches and totems. The argument is optional and defaults to mainhand, so /swing @p and /swing @p mainhand do exactly the same thing.
/swing was added in Java Edition 26.1 and its syntax has not changed since. It requires permission level 2: in singleplayer that means cheats enabled, on a server an operator. Command blocks and datapack functions can run it too, which is how adventure maps animate NPCs for regular players.
Each run of /swing plays one quick swing, so loop it. A repeating command block running /swing @e[tag=actor] re-triggers the animation every game tick, which looks frantic; for a natural mining or fighting rhythm, gate it with a scoreboard timer or a datapack function scheduled every 6 to 10 ticks. Tag your actor entities so one looped command animates the whole scene.
Building a scene? Pose the props too, or browse more Minecraft tools: