Yes, you can compost nettles.
Nettles are considered a natural composting accelerator, especially if you’ve got a “brown“-heavy heap.
You can also use nettles to make a liquid fertiliser for the garden – ferment them in rainwater at a ratio of 10:1 for a few weeks, either in a covered bucket or an old fizzy pop bottle. The result is an iron rich solution that’s great for promoting the growth of green leaves and for building up humus in the soil.
If you are worried about them regrowing or creating a nettle jungle in your garden when you finally use your compost (or using the liquid fertiliser), chop up the plants and avoid composting the roots to get the maximum nettle benefit for the minimum risk.
Away from composting etc, don’t forget that you can also harvest young nettles for use in the kitchen: they can be wilted like spinach or used to make a herbal tea.