Halides in 3D perovskites can be exchanged using halogen gas, while 2D perovskites can be tuned for selective halogen chemisorption.