Electrical box caught on fire
Allow enough space.

A cable is 2-5 wires inside a plastic sheath.  

A #14 wire needs 2.0 cubic inches.
A #12 wire needs 2.25 cubic inches.
A #10 wire needs 2.5 cubic inches.
A #8 wire needs 3.0 cubic inches.
A #6 wire needs 5.0 cubic inches.
Beyond that, it gets complicated.  

All grounds together count as 1 wire of the largest size.  So if you have a bunch of #14-#10 grounds, you get them all for 2.5 cubic inches total. 

Suppose you're extending a 12/2 cable. That's two #12 wires from one cable, two #12 wires from the other cable (four so far).  That makes 2.25 x 4 = 9 cubic inches.  

Now you know how big a box (or boxes) you need. 

Get a taller panel

It's always a blessing to have more spaces anyway, so go for it. You are allowed to splice with wire-nuts inside a panel. 

I prefer to have multiple junction boxes, connected with EMT metal conduit.

If your panel is surface mount, this can work great.  You run a 3/4" EMT conduit pipe some distance from the panel.  You fit either a 4" square deep box (31 cubic inches with a domed cover (10 cubic inches), or a 4-11/16" square box (42 cubic inches).   EMT metal conduit, properly fitted, is the ground path.  So you simply attach a pigtaled ground screw to the screw hole in the box, and tack up your grounds and push em back into the box.  

Then, down the conduit, you extend the wires using THHN individual wires.  You can use all #12 wire, that'll be fine for extending #14 circuits, but mark the #12 with a flag saying "#14" or 15A, so somebody doesn't think it's good for 20A.  

Either the 42 ci box or the 31+10 box+cover give enough room for 4 circuits to be extended.  And that's fine because 4 circuits is the thermal maximum for EMT conduit that is longer than 2 feet. 

Hot-neutral grouping matters.  Wiring is NOT just "every neutral goes to the bar" - it matters which hot(s) it's with, for diagnostic and GFCI/AFCI reasons. Bundle the THHN hot-neutral groups. Wrap the pair with tape somewhere it won't be too intrusive.  I recommend multi-color tape. You can even have pairs of colors, out of 6 colors of tape you can get 21 combinations.  (blue-red and red-blue can't both be used, too confusing). 

Don't catch your panel on fire again.

Do not use Zinsco or Federal Pacific panels, or continue them in use.  

Do not use Brand X panel and put Brand Y breakers in them.  That's not mindless consumerism, the bus stabs actually are different shapes and won't mesh properly cross-brand, and that starts arcing fires.  If you just can't follow this rule, use Eaton CH or Square D QO. That will put you straight :) 

Do not exceed stab limits. So putting the 50A/30A range-water heater quadplex across from the 100A subpanel breaker, is nope. 

If a bus stab is roached, stop using it. Paint a breaker red and stick it there and use it for nothing. 

Cover all unused knockouts to prevent animal entry.