They are created by hardened nectar from Pellet Posies, which, when attacked, will drop the pellets. In Pikmin, the number on the pellet signifies how many Pikmin are required to carry it. They grow inside flowers called Pellet Posies. Pellets come in three colors: red, yellow, and blue (each corresponding to an onion of the same color); and in four sizes: 1, 5, 10, and an exceedingly rare 20. Pellets gradually increase in size if left to grow on their posies.
An 8 pellet was introduced in Hey! Pikmin and is not only exclusive to that game, but the only pellet size available in it.
In Super Smash Bros. Brawl, Super Smash Bros. for Nintendo 3DS, and Super Smash Bros. Ultimate they appear only in the Distant Planet stage. Pellets can be used either as projectile weapons (causing damage proportional to their size), or they can be thrown into an Onion to produce various items. Higher numbered pellets also deal more damage and knockback when thrown.
Any kind of pellet can be thrown into any Onion, but if the color of the pellet matches the color of the Onion, then extra items will be produced. It is a common misconception that better items are received for matching colors or larger pellets, but in fact, only the number of items spawned changes.