The National Electrical Code (NEC) dictates that no wiring splices are allowed outside of an approved enclosure. Any standard outlet, switch box, or light fixture box can serve as an approved enclosure, but where a wiring splice needs to occur in other locations along the circuit, the approved enclosure is usually a junction box.
A junction box is simply a standard electrical box that is mounted securely to the house framing or another structure, containing the connection (splice) of two or more circuit cables. The cables are secured to the box with cable clamps (or conduit connectors, if the circuit includes conduit), and the box must have a removable cover to create a complete enclosure. Junction box covers must remain accessible; they cannot be covered with drywall or other surface material.
A junction box is most often used where an electrical circuit branches off in two or more directions from a location where an outlet or fixture is not practical. It is also a common solution when an electrical circuit is being extended.
Choose the Right Junction Box
Make sure to buy a junction box appropriate for your installation. Outdoor locations, for example, require a weatherproof junction box with gaskets to prevent moisture intrusion. And make sure the junction box is large enough for the number of wiring connections you will be making. For example, the smallest 2-by-4-by-1-1/2-inch-deep box can comfortably splice only two cables (four or five conducting wires), while the largest 4-by-4-by-2-1/8-inch-deep boxes can handle as many as four to six cables (up to 18 individual conducting wires). For easy installation, many DIYers choose the largest box that is practical for the application.
Before You Begin
Turn off the power to the circuit you’ll be working on by switching off the appropriate circuit breaker in your home’s service panel (circuit breaker box). Test all of the wires you’ll be working on with a non-contact voltage tester. The test should confirm that no voltage is present in any of the wires.
Watch Now: How to Install an Electrical Junction Box
Source: The Spruce