There are nine official classes that can be played in Team Fortress 2; they are as follows:
All nine classes are grouped into three specific combat types, offensive, defensive, and support, but all can be played outside their assigned role depending on the player's choice of strategy.
The classes, Scout, Soldier, and Pyro are the main attack force of the team. Whether it's assaulting Control Points or grabbing the Intelligence, these classes focus on mobility. The Scout has the ability to capture points twice as fast as any other class and can get there with their top-tier speed and double jumps. The Soldier can pack a punch with their devastating rocket launchers and can attack from unexpected directions by rocket jumping. The Pyro can wreak fiery havoc in enemy ranks with a well-timed ambush or extinguish their own burning teammates, and offer the highest speed/health ratio of all classes (barring buffs or nonstandard equipment).
The defense classes, Demoman, Heavy, and Engineer serve to inhibit enemy access and to hold enemies back from vital points on the map. Overall, the defensive group has the most firepower of all the groups. Demoman can safeguard areas with stickybombs that they can detonate when pressing Right Click. Heavies are great for mowing down incoming troops and pushing back forces. Heavies can also keep enemies in an area while whittling their health for teammates to finish off. Engineers can build Sentry Guns for effective area defense, as well as build Teleporters and Dispensers for logistical support of the team.
Support classes, Medic, Sniper, and Spy cannot hold the fight on their own, but their specialized abilities can tip the balance in their team's favor. They offer the offensive and defensive classes an extra edge in battle and can help turn the tide of the game. Whether crippling the enemy advance from behind or keeping teammates healed, the support classes are always handy to have around. Medics offer a mobile means of healing for teammates, capable of them to 150% of their maximum health, and can provide a range of buffs such as invincibility, 100% critical hit rate, 300% healing rate as well as immunity to movement impairing effects, or 75% resistance to bullets, explosions or fire. Snipers can eliminate key targets from a distance and use Jarate to extinguish teammates on fire and increase the damage dealt with the enemy. Spies can infiltrate enemy lines undetected, disable buildings, and assassinate critical threats.