Updated:

Basic idea

/playsound minecraft:entity.player.levelup master @a ~ ~ ~ 1 1

Read it left to right: the sound, the source (which volume slider controls it), who hears it, where it plays, then volume and pitch. Adventure maps use it for doors and rewards, and minigames use it for start and finish cues.

Common mistakes

Example: play a note sound in Java Edition

/playsound minecraft:block.note_block.pling master @p ~ ~ ~ 1 1

This example specifies a sound event, sound category, nearest-player target, position, volume and pitch. A listener too far from the source may not hear it. Make sure the sound ID exists in the game version you selected: event identifiers can change across updates.

Check sound settings and position

In a test world, stand close to the command position, enable your audio device and turn up Minecraft's relevant volume controls. Try a simple sound before combining it with an execute command or a chain of command blocks. If the selector matches no players, there is nobody to receive the sound.

Using a command block

A command block runs commands at its own location unless the execution context is changed. Relative coordinates such as ~ ~ ~ therefore refer to that block when used directly inside it. For adventure-map sound cues tied to a player location, investigate execute and test the position explicitly.

Syntax in Java and Bedrock

EditionSyntax
Java/playsound <sound> <source> <targets> [pos] [volume] [pitch] [minVolume]
Bedrock/playsound <sound> [player] [position] [volume] [pitch] [minimumVolume]

Bedrock has no source (category) argument, and many sound names are different. For example, the level-up sound is minecraft:entity.player.levelup in Java but random.levelup in Bedrock.

Useful sounds

UseJavaBedrock
Level up / rewardminecraft:entity.player.leveluprandom.levelup
Experience pickupminecraft:entity.experience_orb.pickuprandom.orb
Note block chimeminecraft:block.note_block.plingnote.pling
Button clickminecraft:ui.button.clickrandom.click
Bellminecraft:block.bell.useblock.bell.hit
Explosionminecraft:entity.generic.exploderandom.explode

Volume, pitch and range

A volume above 1 does not make the sound louder; it makes it audible from further away (roughly 16 blocks per 1.0 of volume). Pitch changes how high the sound is: 1 is normal, 2 is one octave higher and 0.5 is one octave lower. If players far away should still hear a quiet version, set minVolume to a value such as 0.5.

Play a sound for every player at their own position

/execute as @a at @s run playsound minecraft:entity.player.levelup master @s ~ ~ ~ 1 1

Running the command at each player's position means everyone hears it at full volume, wherever they are. This is the usual pattern for minigame start and finish cues.

Stopping a sound

/stopsound @a master minecraft:block.note_block.pling

Leave out the sound name to stop every sound in that source, or leave out both to stop all sounds for the target.

FAQ

Which source should I use?

The source decides which volume slider in the player's settings controls the sound. master follows the overall volume, so it is the safest choice for map cues. Use music or record only for music.

Can I play custom sounds?

Yes. Sounds added by a resource pack can be played by their sound event name, for example /playsound mymap:intro master @a.

Related tools