I'm using the transistor (NPN bjt 2N4401) as a switch to light up 20 leds (leds use 2v 20mA) (my power source is 6V).
20 LEDs times 20 mA each is 400 mA collector current.
Divide that by the current gain to get the minimum required base current. This transistor is specified to have a minimum gain of 100 at 150 mA, and 40 at 500 mA. We will have to go with the 40 value.
(400 mA)/40 = 10 mA, which is the minimum required base current to sustain the required collector current.
Now find the voltage across the base resistor. You say one end will be driven to 6 V. The other end will be the B-E drop above ground, let's say 750 mV. That leaves 5.25 V across the resistor.
By Ohm's law (5.25 V)/(10 mA) = 525 Ω. However, that results in the absolute minimum required base current. I'd use a 470 Ω resistor at least to get some margin.
Now use the above method to work backwards and see what the base current will be, then check that the digital output can support that. If not, you need a different topology with more gain.
In this case, I'd use a small N-channel FET that can be turned on fully with regular logic level voltages, like the IRLML2502. You drive its gate directly from the digital output without a resistor, it's source to ground, and its drain to the bottom ends of the LED strings.