A Wizard knows between 9 and 290 spells in 5e, depending on their level and access to spellbooks. A 1st-level Wizard knows six 1st-level spells and three cantrips. Each time a character gains a Wizard level, they learn two additional Wizard spells for which they have spell slots.
On this basis alone, a Wizard will know the following number of Wizard spells at each level:
|Level||Spells Known||Cantrips Known|
Additionally, a Wizard can copy any Wizard spell of 1st-level or higher from a spell scroll or spellbook into their own spellbook. This costs 50 gp and requires 2 hours per spell level (e.g., a 5th-level spell costs 250 gp and takes 10 hours to learn).
Making a copy of this spell book requires 10 gp and 1 hour per spell level. This is important because if a Wizard loses their spellbook, they also lose all the spells they don’t have prepared at the time of the spellbook’s loss.
Because of this system, a Wizard can technically know every 1st-level spell or higher on the Wizard class spell list, totaling 285 spells (counting only those in the Player’s Handbook, Xanathar’s Guide to Everything, and Tasha’s Cauldron of Everything). A Wizard can learn a maximum of 5 cantrips starting at 10th level. Together, this means the maximum spells a Wizard can know is 290.
A Wizard can technically achieve this feat at 17th level. However, most campaign settings don’t feature enough spell scrolls and/or spell tomes to allow for a Wizard to actually learn every spell on their spell list by 20th level.
Note that multiclassing, especially to a class with access to more cantrips and primal/divine spells, can net a character an even greater number of spells.
Player’s Handbook, page 113-4