Updated:

1. Remove all trees (Java)

/fill ~-15 ~ ~-15 ~15 ~25 ~15 minecraft:air replace #minecraft:logs
/fill ~-15 ~ ~-15 ~15 ~25 ~15 minecraft:air replace #minecraft:leaves

#minecraft:logs and #minecraft:leaves are block tags covering every log and leaf type. The area is 24986 blocks, under the usual 32768 limit.

2. Grass and flowers

/fill ~-15 ~ ~-15 ~15 ~3 ~15 minecraft:air replace minecraft:short_grass
/fill ~-15 ~ ~-15 ~15 ~3 ~15 minecraft:air replace minecraft:tall_grass
/fill ~-15 ~ ~-15 ~15 ~3 ~15 minecraft:air replace #minecraft:flowers

Short grass is grass before 1.20.3.

3. Snow

/fill ~-15 ~ ~-15 ~15 ~3 ~15 minecraft:air replace minecraft:snow

4. Bedrock

/fill ~-15 ~ ~-15 ~15 ~25 ~15 air replace oak_log
/fill ~-15 ~ ~-15 ~15 ~25 ~15 air replace oak_leaves

Bedrock fill has no block tags, so run it per wood type: birch_log, spruce_log and so on.

5. Larger areas

One fill can change at most 32768 blocks on Java. For a bigger forest, walk 30 blocks and run the commands again, or raise the limit on a test world with /gamerule max_block_modifications 100000 (called commandModificationBlockLimit on 1.20.3 to 1.21.10). Bedrock has no such rule, so split the area.

Troubleshooting

See the fill command for limits and the remove water command for another replace trick.

Check your command

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