/swing Command in Minecraft Java Edition

Trigger Arm Swing Animations for Players and Entities

Java EditionPlayers & EntitiesPermission: Level 2Added in 26.1

The /swing command forces a player or entity to play an arm swing animation. You can choose whether they swing their mainhand or offhand, and in version 26.3 and later, you can also pick a specific swing animation and how long it lasts.

Map makers and server creators use this command to make mobs or NPCs look like they are attacking, interacting with blocks, or waving at players without needing direct player input.

Syntax (Java 26.3, 6 forms)

  1. /swing
  2. /swing <targets>
  3. /swing <targets> mainhand
  4. /swing <targets> mainhand <animation> [<duration>]
  5. /swing <targets> offhand
  6. /swing <targets> offhand <animation> [<duration>]

The forms you will use most

/swing
Plays the default swing animation for the entity or player running the command.
/swing <targets>
Plays the default swing animation on the chosen targets.
/swing <targets> mainhand
Forces the chosen targets to swing their mainhand.
/swing <targets> mainhand <animation> [<duration>]
Forces the targets to swing their mainhand using a specific animation and an optional duration.
/swing <targets> offhand
Forces the chosen targets to swing their offhand.
/swing <targets> offhand <animation> [<duration>]
Forces the targets to swing their offhand using a specific animation and an optional duration.

Arguments

ArgumentTypeWhat it means
<targets>target selectorSpecifies who performs the swing using a player name, a UUID, or a target selector like @p, @a, @e, or @s.
<animation>swing animationSpecifies the swing animation to play on the target's arm.
<duration>time
at least 1
Sets how long the animation lasts using a time value of at least 1, such as 100 (ticks), 5s, or 2d.

Examples

Version history

Measured from the game files of every Java release from 1.13 to 26.3.

  1. 26.3 Syntax changed.
    + /swing <targets> mainhand <animation> [<duration>]+ /swing <targets> offhand <animation> [<duration>]
  2. 26.1 Command added.

Tips

Common mistakes

Java vs Bedrock

Minecraft Bedrock Edition does not have a /swing command, as this feature is exclusive to Java Edition starting in version 26.1.

FAQ

When was the /swing command added to Minecraft?

The /swing command was first added to Minecraft Java Edition in version 26.1, and its syntax was expanded in version 26.3 to include animation and duration arguments.

Can I make a player swing their offhand?

Yes, you can specify either mainhand or offhand right after the target selector to choose which arm performs the swing.

Is the /swing command available in Bedrock Edition?

No, Bedrock Edition does not have a command with this name, and it only works in Java Edition with operator permissions enabled.

Related commands

/advancement/attribute/damage/defaultgamemode/effect/experience/gamemode/kill/ride/rotate/spawnpoint/spectate/spreadplayers/summon/teleport/tp