Rowling has never revealed specific numbers; but we can come up with a starting point.
Identified by the text - Hogwarts: about 152-207, Voldemort: 19-32
The Harry Potter Lexicon identifies 69 named or identified participants1: 51 on the Hogwarts side, the rest on Voldemort's side.
They have a couple of omissions:
- Kreacher, who lead the House-Elf charge
- Walden Macnair
And there are some vagueries that we can try to clear up:
Remaining Hogwarts teachers: In addition to the eight professors listed in the Lexicon (Snape, McGonagall, Flitwick, Sprout, Slughorn, Trelawny, Hagrid, and Firenze), we could potentially add any of the following:
- Professor Sinistra
- Professor Babbling (the Ancient Runes teacher)
- Madame Hooch
- Professor Vector
- Madame Pince
If there are any more teachers, they're not identified.
Death Eaters: We know a few Death Eaters who aren't explicitly seen in the battle. Though some of them may not have participated in the battle (due to injury, death, or capture in a previous skirmish), we could potentially expand Voldemort's side to include any of:
- Avery, Sr.
- Avery, Jr.
- Crabbe, Sr.
- Goyle, Sr.
- Lestrange, Sr.
- Mulciber, Sr.
- Mulciber, Jr.
- Nott, Sr.
- Rabastan Lestrange
- Rodolphus Lestrange
- Rosier, Sr.
House-Elves: In Goblet of Fire, Harry sees at least a hundred House-Elves in the Hogwarts kitchens. Although this is obviously an estimate, it's something, and the nature of House-Elves suggests that all of them would fight.
This puts us at a something between 17-30 on Voldemort's side, and about 152-157 on the Hogwarts side.
The Lexicon also states that at least 50 died on the Hogwarts side. That number is taken from the following quote:
They moved Voldemort's body and laid it in a chamber off the Hall, away from the bodies of Fred, Tonks, Lupin, Colin Creevey, and fifty others who died fighting him.
Deathly Hallows Chapter 36: "The Flaw in the Plan"
From the list of Hogwarts participants (excluding Fred, Lupin, Tonks, and Colin), we can be certain that 26 survived the battle2:
Snape is also definitely not counted among that 50, since Harry left his body in the Shrieking Shack and didn't have time to tell anyone about it.
On the "minimum" end of the spectrum, it's remotely possible that all fifty bodies belong to House-Elves; on the "maximum" end, all fifty could belong to unnamed characters. So we could potentially have zero additional participants, or at least fifty.
However, bear in mind that "fifty" is likely a guesstimate. It's unlikely that Harry stopped to count all the bodies, but rather just saw a reasonably-sized quantity and made a judgement call.
Not counted in-text, but loosely estimable
Dementors: The Pottermore entry on Dementors3 gives us a couple of useful tidbits:
The Law of Conservation of Dementors: As far as anybody knows, it's not possible to kill a Dementor. However, it is possible for them to grow, under the right conditions. Conditions such as Azkaban, where they've been breeding for about 500 years. The upshot of this is that the number of Dementors willing to fight for Voldemort (and we have to assume that's all of them) is never going to go down.
A very rough population number. According to Pottermore, there are "thousands of Dementors" in Azkaban. This may be a hyperbole, but actually doesn't sound that implausible; cursory research into fungal growth (which is what Dementors grow like) suggests that fungi can grow exponentially under optimal conditions, and the Dementors have had optimal conditions for five hundred years.
Now it's likely that not all of the Dementors participated in the Battle of Hogwarts: a significant number of them seemed to be roaming the country aimlessly, and still more were being used in the Ministry of Magic for nefarious purposes, but I think it's safe to say that at least 100 would have participated.
Giants: In Order of the Phoenix, Hagrid gives us a pretty depressing bound on the number of giants left in the world:
'And how many were there?' asked Harry.
'I reckon abou' seventy or eighty,' said Hagrid.
'Is that all?' said Hermione.
'Yep,' said Hagrid sadly, 'eighty left, an' there was loads once, musta bin a hundred diff'rent tribes from all over the world. Bu' they've bin dyin' out fer ages. Wizards killed a few, o' course, bu' mostly they killed each other, an' now they're dyin' out faster than ever. They're not made ter live bunched up together like tha'. Dumbledore says it's our fault, it was the wizards who forced 'em to go an' made 'em live a good long way from us an' they had no choice bu' ter stick together fer their own protection.'
Order of the Phoenix Chapter 20: "Hagrid's Tale"
Of course, in the handful of days Hagrid and Madame Maxine were among the Giants, yet more of them were killed for not wanting to ally with the Death Eaters. Presumably most of them would have participated in Voldemort's battles; considering the punishment, it's unlikely that more than 15 would have resisted. Of course we don't know how many of those were at Hogwarts (other than the two mentioned above), but we have a range of between about 50-80.
Not remotely estimable from the text
Other students: McGonagall explicitly allows all students who are "of-age" (that is, aged 17 or older) to stay and fight:
"...evacuation will be overseen by Mr. Filch and Madame Pomfrey. Prefects, when I give the word, you will organize your House and take your charges in orderly fashion to the evacuation point."
Many of the students looked petrified. However, as Harry skirted the walls, scanning the Gryffindor table for Ron and Hermione, Ernie Macmillan stood up at the Hufflepuff table and shouted; "And what if we want to stay and fight?"
There was a smattering of applause.
"If you are of age, you may stay." said Professor McGonagall.
**Deathly Hallows* Chapter 31: "The Battle of Hogwarts"
However, we know that more students than this participated; roughly half of Dumbledore's Army is underage, including Ginny and Colin Creevy. At most 100% of the current student body participated (and remember that all Muggleborns had been forbidden from attending, so that drops the regular by an unspecified amount), but standard enrolment figures are hard to come by.
Even if we take
Rowling's Slytherincess' estimate of 250 per house, we have no idea what percentage of them even attended that year (either because they were muggleborn, unable to prove their blood status, or faked an illness like Ron did), or how many actually participated in the battle (on either side). I might conservatively say that 500 of them participated, but that's nothing more than a guess
Death Eaters We know Voldemort was doing some recruitment, but we don't have any idea how successful he was. I included named Death Eaters above, but this list could potentially expand to include any number of unseen Death Eaters and Snatchers.
Other Non-human creatures: Mainly the Centaurs, Suits of Armour, and Acromantulae. The collective number of suits of armour are described by Harry as a "horde", which suggests so many that he couldn't eyeball them, but that doesn't tell us much. Five hundred? A thousand? We don't know. I could perhaps estimate the number of Acromantula in the Hogwarts colony, since it started with two spiders, starting between 1943 and (probably) 1945. I could do this, but reading studies on spider reproduction is not my idea of a fun evening. Use your imaginations.
1 I'm ignoring large groups of uncountable people (like "rest of Hogwarts staff") for reasons that should be obvious. I'm also ignoring Filch, because he wasn't actually a participant. However, I am counting the two giants, because the text tells us that Harry encounters two separate giants.
2 "Certainty" here meaning that there is a reference to them after Voldemort's death; either in the book, or in Pottermore content
3 Also available here if you don't have a Pottermore account