The main series games? What most people think of when they think "Pokemon Games", there are 9: Diamond, Pearl, Platinum, Heart Gold, Soul Silver, Black, White, Black 2 and White 2.
In total, including spin off games? Including only those that released internationally, 20: the 9 main series games above, Blue Rescue Team, Explorers of Time, Explorers of Darkness, Explorers of Sky, Ranger, Ranger: Shadows of Almia, Ranger: Guardian Signs, Trozei, Dash, Typing Adventure and Conquest.
If you're including 3ds, that increases it again: 8 more main series games: X, Y, Omega Ruby, Alpha Sapphire, Sun, Moon, Ultra Sun and Ultra Moon, as well as 10 side games: Dream Radar, Detective Pikachu, Gates to Infinity, Super Mystery Dungeon, Picross, Rumble Blast, Rumble World, Shuffle, Battle Trozei and Art Academy. There are also 8 virtual console games: Red, Blue, Yellow, Gold, Silver, Crystal, Trading Card Game and Puzzle Challenge. Then you have Bank and Transporter which aren't games, but are important to the series. You also have the Omega Ruby and Alpha Sapphire as well as the Sun and Moon demos.
Hope this extremely detailed comment helped.