I'm running my first campaign and I'm confused about the CR of monsters. I started out with five level 2 characters. I have a few encounters that work so far, but theres one I'm confused about. If the CR of a monster 1/4, and the characters are now level 3, with a lvl 1 NPC and a lvl 5 NPC. How many of these CR 1/4s will it take to be a challenge?
[This all assumes you're looking for a medium encounter, as defined in the DMG. Adjust upward or downward for easy, hard, or deadly, as instructed in the various sections.]
By the DMG
"Creating a Combat Encounter" (pp.81-84) has your instructions. For example, a "medium" encounter for a party of 5 level 3 PCs would have an adjusted XP budget of 750--1125.
A CR 1/4 creature is valued at 50XP (MM. p.9), so we can fiddle with numbers and encounter multipliers (DMG p.82) to see that 6 creatures would be too few, 9 would verge on "hard." So your answer's 7 or 8, possibly 9.
"Encounter Building" (pp.88-91) has more guidelines. There we'd see that for level 3 characters I should provide CR1/4 enemies in a 2:1 ratio. So XGtE recommends 10 of them.
By the sheep
I say throw anywhere between six and ten at them, depending on what makes sense in the fiction. Then use your gameplay and game-time decisions to adjust difficulty as it goes. If ten's too many have a few cowardly ones break off the first time one goes down. If six is too few, have them fight smart. (Placing the encounter in terrain/location that you can choose to use to your advantage--or not--is key to this, I believe. Personally I'm not a fan of bringing in reinforcements unless the party knows they're in a monster-ridden location like a hostile camp, but others report success with that tactic.)
The quick calculation I use is to try and make sure the monsters are dishing out damage about 1/2 the rate the party generally does.* Your L3 adventurers are probably dishing out about 10 or 12 dmg per round, hitting 2/3 of the time, for a party total of 35-40. How many CR 1/4 does it take to dish out 1/3 of that? Say they do 6 dmg per round at the same hit-rate, we're looking at 5 monsters. But it's nicer to have too many than to have too few--it's much easier to "dial back" as a GM--so that's where the recommendation of 6-10 comes in.
* - This is based on the notion of six encounters and two short rests per adventuring day; if a "medium" encounter starts its lifecycyle dishing out 1/2 the party's damage and decreases somewhat-linearly (as monsters start dropping) to 0, the time-averaged damage output sits around 1/4 the party's. But monsters don't always drop that quickly (though these little ones will), so the real time-average is a little higher, call it 1/3. Which is what I really want from a medium encounter so that two of them will make the party want for a short rest, and an "easy" should be easier than that and a "hard" has room to be noticeably harder.
There is this site called "kobold fight club" which helps building encounters https://kobold.club/fight/#/encounter-builder