For freshwater: 6-10 small community fish (tetras, rasboras, dwarf corydoras) plus a single centerpiece (a betta, dwarf gourami, or pair of small rams). For saltwater: 2-3 small fish total - a clownfish pair plus one small goby or watchman is the realistic max in a 20-gallon reef. The old "1 inch per gallon" rule is wrong for both.
The "inch per gallon" rule was made up before anyone understood bioload. A 20-gallon tank can hold dozens of harlequin rasboras (1.5 inches each) but only one bichir (8 inches). Bioload is what matters - waste production, oxygen demand, and territorial space.
A 20-gallon nano reef tops out at 2-3 small fish. Realistic options:
Saltwater fish produce more waste per inch than freshwater fish, the water holds less oxygen at higher salinity, and the smaller water volume of a nano amplifies parameter swings. A 20-gallon reef with three fish runs cleanly; a 20-gallon reef with five fish struggles.