Herodotus mentions 300 Spartan soldiers (Spartiates) and a total of 3100 Peloponnesian hoplites (7.202). In 7.228.1 Herodotus says 4000 men from the Peloponnese were at Thermopylae, a figure that doesn't add up when you add in the allies.
The Hellenes who awaited the Persians in that place were these: three hundred Spartan armed men; one thousand from Tegea and Mantinea, half from each place; one hundred and twenty from Orchomenus in Arcadia and one thousand from the rest of Arcadia; that many Arcadians, four hundred from Corinth, two hundred from Phlius, and eighty Mycenaeans. These were the Peloponnesians present; from Boeotia there were seven hundred Thespians and four hundred Thebans.
Diodorus says there were 300 Spartiates plus 700 Lacedaemonians. His force of 4000 men included 3000 other Greeks (11.4.5-6). Isocrates, in his Panegyricus 90 and Archidamus 99 also mentions a total of 1000 Lacedaemonians.
Isocrates Panegyricus 90
It was one, then, of such lofty pride and such great achievements, master of so many men, that they went to encounter, dividing the risk between them,--the Lacedaemonians to Thermopylae against his land forces, choosing a thousand of their number and taking a few of their allies with them, intending in the narrow pass to bar their further advance, and our ancestors to Artemisium,68 having manned sixty triremes against the whole fleet of the enemy.
Isocrates Archidamus 99
Remember the men who at Dipaea fought against the Arcadians, of whom we are told that, albeit they stood arrayed with but a single line of soldiery, they raised a trophy over thousands upon thousands; remember the three hundred who at Thyrea defeated the whole Argive force in battle; remember the thousand who went to meet the foe at Thermopylae,  who, although they engaged seven hundred thousand of the barbarians, did not flee nor suffer defeat, but laid down their lives on the spot where they were stationed, acquitting themselves so nobly that even those who eulogize them with all the resources of art can find no praises equal to their valor.
Herodotus says that of the allied troops, the Thebans were kept against their will:
Those allies who were dismissed went off in obedience to Leonidas, only the Thespians and Thebans remaining with the Lacedaemonians. The  Thebans remained against their will and desire, for Leonidas kept them as hostages. The  Thespians very gladly remained, saying they would not abandon Leonidas and those with him by leaving....
Diodorus says Leonidas used 200 Thespians from among the allies as well as 400 willing Thebans to go against Xerxes at Thermopylae. Justin (2.11.11-15) says only Lacedaeomonians remained after Leonidas dismissed the allies before confronting the Persians, and their number was 600. Herodotus said Leonidas had 700 Thesbians and 400 Thebans with him when he dismissed the allies.
As with most stories from ancient history, so also with the story of the 300 there are conflicting reports; however, the battle at Thermopylae epitomizes the bravery of the Spartans and their allies under Leonidas.
References for the Battle of Thermopylae
- Simonides, Fragm. 92 William C. McDermott The Classical Journal, Vol. 40, No. 3. (Dec., 1944), pp. 168-170.
- Simonides, Ephorus, and Herodotus on the Battle of Thermopylae Michael A. Flower The Classical Quarterly, New Series, Vol. 48, No. 2. (1998), pp. 365-379.
- vs Hdt 7.223
- Diodorus Siculus, Library
- The Malice of Herodotus, by Plutarch