Updated:

Summon lit TNT

VersionCommand
Java Edition/summon minecraft:tnt ~ ~ ~3
Bedrock Edition/summon tnt ~ ~ ~3

This spawns lit TNT three blocks away. With no settings it explodes after 80 ticks (4 seconds). Do not summon it at your own feet.

Change the fuse (Java)

VersionExplode after 2 seconds
Java 1.20.3 and later/summon minecraft:tnt ~ ~ ~3 {fuse:40}
Java 1.20.2 and earlier/summon minecraft:tnt ~ ~ ~3 {Fuse:40}

The number is in ticks (20 ticks = 1 second). {fuse:0} explodes immediately. Java 1.20.3 renamed Fuse to lowercase fuse, so commands from older tutorials no longer change the time. Bedrock cannot set the fuse with /summon.

TNT rain

/execute at @a run summon minecraft:tnt ~ ~10 ~ {fuse:60}

This drops lit TNT ten blocks above every player (Java 1.20.3+). A longer fuse lets it land before exploding. On Bedrock use /execute at @a run summon tnt ~ ~10 ~.

Place TNT blocks

/fill ~2 ~ ~2 ~6 ~ ~6 minecraft:tnt

TNT placed with /fill is not lit; ignite it with flint and steel or redstone. Large amounts can freeze the world, so keep the area small.

Launch TNT upward or sideways

/summon minecraft:tnt ~ ~1 ~ {fuse:60,Motion:[0.0,1.2,0.0]}

Motion sets the starting speed in X, Y and Z. This throws the TNT straight up so it explodes in the air. Change the first or third number to fire it sideways, like a cannon. Use Fuse instead of fuse on 1.20.2 and earlier.

A bigger explosion

TNT always has the same power. For a larger blast, summon a creeper that is already lit and has a bigger radius:

/summon minecraft:creeper ~ ~ ~6 {ExplosionRadius:6b,Fuse:0,ignited:1b}

A normal creeper has radius 3. The creeper's Fuse keeps its capital F in every Java version; only the TNT tag was renamed. Very large radii can crash weaker computers, so stay under about 10.

Protect terrain

On Bedrock, /gamerule tntexplodes false stops TNT from exploding. Newer Java versions have a similar rule, but its name depends on the version; type /gamerule and pick the rule containing tnt from the suggestions (see the gamerule list). Turning off mobGriefing does not stop TNT.

Common problems

Check your command

The Command Error Doctor checks common syntax mistakes in your browser.