Oh, you may not think I'm pretty,
But don't judge on what you see,
I'll eat myself if you can find
A smarter hat than me.
You can keep your bowlers black,
Your top hats sleek and tall,
For I'm the Hogwarts Sorting Hat
And I can cap them all.
There's nothing hidden in your head
The Sorting Hat can't see,
So try me on and I will tell you
Where you ought to be.
You might belong in Gryffindor,
Where dwell the brave at heart,
Their daring, nerve and chivalry,
Set Gryffindors apart;
You might belong in Hufflepuff
Where they are just and loyal,
Those patient Hufflepuffs are true,
And unafraid of toil;
Or yet in wise old Ravenclaw,
If you've a ready mind,
Where those of wit and learning,
Will always find their kind;
Or perhaps in Slytherin,
You'll make your real friends,
Those cunning folk use any means,
To achieve their ends.
So put me on! Don't be afraid!
And don't get in a flap!
You're in safe hands (though I have none)
For I'm a Thinking Cap!"Random Facts About The Sorting Hat
The famous Hogwarts Sorting Hat gives an account of its own genesis in a series of songs sung at the beginning of each school year. Legend has it that the hat once belonged to one of the four founders, Godric Gryffindor, and that it was jointly enchanted by all four founders to ensure that students would be sorted into their eponymous houses, which would be selected according to each founder's particular preferences in students.The Sorting Hat is one of the cleverest enchanted objects most witches and wizards will ever meet. It literally contains the intelligence of the four founders, can speak (through a rip near its brim) and is skilled at Legilimency, which enables it to look into the wearer's head and divine his or her capabilities or mood. It can even respond to the thoughts of the wearer.
The Sorting Hat is notorious for refusing to admit it has made a mistake in its sorting of a student. On those occasions when Slytherins behave altruistically or selflessly, when Ravenclaws flunk all their exams, when Hufflepuffs prove lazy yet academically gifted and when Gryffindors exhibit cowardice, the Hat steadfastly backs its original decision. On balance, however, the Hat has made remarkably few errors of judgement over the many centuries it has been at work.
Rowling's thoughts
The Sorting Hat does not appear in my earliest plans for Hogwarts. I debated several different methods for sorting students (because I knew from early on that there would be four houses, all with very different qualities). The first was an elaborate, Heath Robinson-ish machine that did all kinds of magical things before reaching a decision, but I did not like it: it felt at once too complicated, and too easy. Next I placed four statues of the four founders in the Entrance Hall, which came alive and selected students from the throng in front of them while the school watched. This was better, but still not quite right. Finally, I wrote a list of the ways in which people can be chosen: eeny meeny miny mo, short straws, chosen by team captains, names out of a hat - names out of a talking hat - putting on a hat - the Sorting Hat.
JK Rowling said that the Sorting Hat only made 7 mistakes, one of them being sorting Snape into Slytherin.