The answer to 'what size junction box do I need' is that the size of the junction box you need depends on the number and size of the wires and devices it will contain. As a general guideline, you'll want to use a junction box that is large enough to accommodate all the wires and connections comfortably, with some extra space to work. For most residential applications, a 4-inch square or 4-inch round junction box is a common choice.
When selecting a junction box, consider the number of wires and devices you need to connect, as well as the size of the wires. The box should be large enough to fit all the wires without overcrowding, and have enough space for making connections and securing devices. It's also important to choose a junction box that is rated for the type of installation, such as being suitable for wet locations or fire-rated construction.