Founder's era (about 900AD)
The Sorting Hat is a sentient Hogwarts artefact which magically determines to which of the four school Houses each new student is to be assigned. These four Houses are Gryffindor, Hufflepuff, Ravenclaw and Slytherin.
The Sorting Hat originally belonged to Godric Gryffindor, one of the founders of Hogwarts. It normally stays in the Headmaster's office until it is needed; Harry Potter talked to the Sorting Hat for the second time when he was sent to Dumbledore's office for the first time in his second year.
During the opening banquet at the beginning of each school year, the first-year students are lined up and their names read aloud alphabetically. Each then takes a seat on a stool and the hat is placed on her or his head. The hat is battered and old; it's patched, frayed, and extremely dirty. In order to speak and sing, a tear along the brim opens like a mouth. It speaks inside of the hat with a small, quiet voice to the wearer and it can use Legilimency to interpret their thoughts and respond to them. After a moment of consideration, the hat announces its choice aloud for all to hear, and the student joins the selected house. The moment of consideration varies in length, from nearly five minutes (known as "hatstall") to less than a second. Judging from Harry's own account of his Sorting, and a brief comment made by Hermione, the hat may sometimes speak to the student during the Sorting.
The Sorting Hat was sewn roughly one thousand years ago and was merely a normal hat belonging to Godric Gryffindor. When Gryffindor, along with Salazar Slytherin, Rowena Ravenclaw and Helga Hufflepuff, wondered how they would continue to sort the students when the four were dead, Gryffindor pulled his hat off of his head and, with the other founders, enchanted it with brains and some amount of personality. The Sorting Hat, now animated, was able to Sort and divide the students into the Hogwarts Houses, and continued to do so for a millennium, being owned by each Headmaster and Headmistress. It does so at the beginning of the start-of-term feast, when it is placed on a three-legged (sometimes four-legged) stool in front of the Great Hall. Godric Gryffindor's Sword, one of the founder's only other known relics, can be magically pulled out of the hat by any Gryffindor considered worthy, no matter how secure the sword's location.
The Sorting Hat's songs
Before sorting the students each year, the hat recites a new introductory song. These songs vary in length and content though they generally introduce the hat and its role in sorting new students. Ron Weasley expressed the opinion that the Hat spends the entire school year making up its next song.
They also occasionally warn of danger to come, as in its 1995 song, though it is not known how the Hat is aware of upcoming events. It was suggested that the Hat picks up some of its information from Albus Dumbledore, though it is not known whether it would have done so before such an influential figure in the wider wizarding world was in office.
Oh you may not think I'm pretty,
A thousand years or more ago
In times of old, when I was new,
Good Hufflepuff, she took the rest
The Sorting Hat with students
The Sorting Hat appeared to have a difficult time in the sorting of Harry Potter. It suggested great fame and glory would be found through joining SlytherinHouse, but Harry requested specifically and emphatically to be spared that fate. It was this choice that prompted the Hat to instead place him into Gryffindor, wherein both his parents had also been Sorted. When Harry spoke to the Hat for the second time, it repeated its earlier declarations - that Harry was particularly hard to sort, and that he would have done well in Slytherin.
In Harry's second year at Hogwarts, the Hat also played a critical role in Harry's success against the Basilisk. Fawkes valiantly brought the Sorting Hat to Harry's aid in the Chamber of Secrets, providing him with Godric Gryffindor's Sword, which Harry used to slay the Basilisk. The sword and hat together are the two known relics of that wizard.
Almost two decades after the Battle of Hogwarts, Albus Severus Potter, son of Harry Potter, expressed worry over his own Sorting, indicating that the Sorting Hat had been repaired or had survived unharmed.
- "Ah, right, then. Hmm, right. Okay. GRYFFINDOR!"
- —Hermione sorted into Gryffindor house[src]
The Sorting Hat also appeared to have had a disagreement in the sorting of Hermione Granger, as her expansive intelligence and future of being the best student in her year saw her as being well suited for Ravenclaw. This is a fact that is brought up in 1995 by several Ravenclaw students during the formation of Dumbledore's Army. However, it can be argued that Hermione saw a greater challenge in herself in becoming bold and courageous, some of the traits of Gryffindor House. This can be clearly seen when Hermione doubts books and cleverness as the traits of a great witch and instead shows that friendship and bravery are more important.
- "Ah, another Weasley. Well, I know just what to do with you. GRYFFINDOR!"
- —Ron sorted into Gryffindor house[src]
It was not hard for the Sorting Hat to place Ron Weasley, as all the Weasley family have been placed into Gryffindor House. Ron was afraid that he would be the only Weasley not to make it into Gryffindor.
The moment the Sorting Hat touched Draco Malfoy's head, the hat instantaneously declared "Slytherin!" In addition to having a selfish and conniving streak, Malfoy is a pure-blood, like most Slytherins, and most of his family was sorted into that house, including his parents Lucius and Narcissa Malfoy, and his aunt Bellatrix Lestrange.
According to Albus Dumbledore, the Sorting Hat declared Tom Riddle a Slytherin almost instantly after it touched his head, a description very similar to Draco's sorting. In addition to having many of the qualities associated with the founder of his house, he was the last surviving descendant of Salazar Slytherin.
The Sorting Hat took a long time to decide upon where to put Neville Longbottom. During his sorting Neville Longbottom argued with the hat, insisting he should be placed in Hufflepuff, while the hat wished to sort him into Gryffindor. Neville was intimidated by Gryffindor's reputation, however his persistance did not work and the hat successfully sorted him into Gryffindor.  Considering not only the bravery and leadership he showed during his seventh year at Hogwarts, but also the fact that he was brave enough to stand up to Harry, Ron and Hermione during their first year, this seems most appropriate.
After his turn with the hat Neville ran off still wearing it and had to return it to its stool.
In 1998 at Hogwarts, Lord Voldemort attempted to destroy the Hat by setting it on fire while it was on Neville Longbottom's head. Neville was able to draw from it the Sword of Godric Gryffindor, which he then courageously used to behead Nagini. However it is unclear if any damage was done to the Hat, because of Harry's earlier sacrifice, which prevented Voldemort's spells from harming those Harry cared about.
The Sorting Hat considered Sorting Filius Flitwick into Gryffindor before choosing Ravenclaw. Later, he became a teacher at Hogwarts and head of his house, and joked with Minerva McGonagall about the fact that they had the opposite experiences and if things had gone another way, they could have had each others' jobs.
The Sorting Hat considered Sorting Minerva McGonagall into Ravenclaw before choosing Gryffindor. Later, she became a teacher at Hogwarts, and put the Sorting Hat on the heads of new students.
Lord Voldemort placed the Sorting Hat on Neville during the Battle of Hogwarts and caused it to burst into flames. However, when reinforcements arrived, Neville was able to break free of the Body Bind and draw the Sword of Gryffindor from the Hat to kill Nagini. The details of what happened to the hat after it was set on fire are unknown. However years later when Harry's son, Albus, expressed his fear of being in Slytherin, Harry told him that the hat takes what you want into consideration, suggesting that a hat still being used to sort out students, though whether it is the same one or not is unknown.
Personality and traits
Though it's a hat, The Sorting Hat is sentient and therefore has its own personality. At the beginning of every term, the hat sings a new song (which Ron Weasley speculated it spent the rest of the year thinking up) describing each of the four houses of Hogwarts. Despite its use in the purposes of "sorting," the Hat has been known to urge students to maintain a united front in the face of adversity and danger.
- In an interview, when asked about the Sorting Hat, Rowling stated that it had never been wrong and asked for theories, though no specific character was mentioned. In exclusive content released for Pottermore, however, she was a bit more shrewd, stating that it "has made remarkably few errors of judgement over the many centuries it has been at work." She also stated that in those cases where students did not exhibit the qualities traditionally associated with their house, or were noted for those associated with others, "the Hat steadfastly backs its original decision."
- According to J. K. Rowling, Sorting Hat wasn't her first idea of how new Hogwarts student shall be sorted into Houses. She wrote:
- "The Sorting Hat does not appear in my earliest plans for Hogwarts. I debated several different methods for sorting students (because I knew on early from that there would be four houses, all with very different qualities). The first was an elaborate Heath Robinson-ish machine that did all kind 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."
- —J. K. Rowling's thought.[src]
Behind the scenes
- It seems that the Sorting Hat tends to place students based on qualities they value rather than qualities they personify. This is never more apparent than with Peter Pettigrew, who was Sorted into Gryffindor but ultimately turned out to be quite cowardly, self-serving and corruptible. He was probably placed there because at the time, he admired strong, brave individuals like James Potter and Sirius Black. Though it is possible Pettigrew was placed in Gryffindor because he aspired to these qualities.
- The Sorting Hat can detect nascent qualities in a student and place them in the House that will challenge them the most and put their character to the test. Case in point, Neville Longbottom is Sorted into Gryffindor because the Hat sensed that he was capable of demonstrating bravery and leadership during his time at Hogwarts. However, these qualities do not fully surface until he learns to believe in himself.
- The Hat also appeared to take each student's wishes into account. Just because someone is placed in a certain House does not mean that they can not possess characteristics of other Houses. Harry Potter, for instance, embodies many of the traits that are appreciated by Salazar Slytherin. He is clever, resourceful and cunning, yet the Sorting Hat made him a Gryffindor because he did exhibit the traits of Gryffindor as well. However, the hat denied Neville from being in Hufflepuff even though he begged for it. This shows that perhaps it took Harry's in account because Harry would have been successful in either house.
- Another prime example of this happening is Severus Snape. At one point, Albus Dumbledore said that his loyal, courageous nature was much more befitted to Gryffindor. However, as a child, Snape's sheer ambition, social climbing behavior and tolerance for sadism made him an obvious Slytherin when he first came to Hogwarts.
- It is possible that the Sorting Hat had trouble with Harry Potter's son, Albus Potter. Albus might have asked not to be in Slytherin, as Harry told Albus that the Sorting Hat takes your choice into account.
- In the film adaptation of Harry Potter and the Philosopher's Stone, the Sorting Hat appears to speak so all the students can hear, whereas in the book the Sorting Hat speaks so only the wearer can hear.
- In the first two Harry Potter films, it is voiced by actor Leslie Phillips.
- Songs are only featured in books 1, 4, and 5, and are omitted entirely from the films.
- Harry was not physically present for the Sorting Hat's songs in books two, three, six and seven. Harry was, however, present for the song and Sorting ceremony in the third movie.
- In the American edition of Harry Potter and the Philosopher's Stone, Harry saw that "there were only three people left to be sorted," but then Professor McGonagall read off four more names (Dean Thomas, Lisa Turpin, Ron Weasley and Blaise Zabini). Dean Thomas did not appear in the British edition. It is possible, however, that Harry did not see one of the first-years ahead of him.
- The Sorting Hat bears a certain resemblance to The Archchancellor's Hat from Terry Pratchett's Discworld novel Sourcery
- A LEGO version of the Sorting Hat was released, entitled 4701 Sorting Hat. It featured a dial with the four house symbols on it that could be spun to land on one and sort the figures.
- One of the possible choices on the W.O.M.B.A.T. aptitude test was that the hat was stolen and substituted by delinquent students in 1325, and the whereabouts of the real hat remain unknown.
- One can purchase a copy of the Sorting Hat at The Wizarding World of Harry Potter.
- The Sorting Hat almost placed Harry into Slytherin because it detected the piece of Voldemort in him.
- Prior to creating the Sorting Hat, Rowling considered using a Magical Gateway or founder statues.
- Harry Potter and the Philosopher's Stone (First appearance)
- Harry Potter and the Philosopher's Stone (film)
- Harry Potter and the Philosopher's Stone (video game) (Voice only)
- Harry Potter and the Chamber of Secrets
- Harry Potter and the Chamber of Secrets (film)
- Harry Potter and the Chamber of Secrets (video game)
- Harry Potter and the Prisoner of Azkaban (Mentioned only)
- Harry Potter and the Goblet of Fire
- Harry Potter and the Goblet of Fire (film)
- Harry Potter and the Order of the Phoenix
- Harry Potter and the Order of the Phoenix (film)
- Harry Potter and the Order of the Phoenix (video game) (Mentioned only)
- Harry Potter and the Half-Blood Prince (Mentioned only)
- Harry Potter and the Half-Blood Prince (film)
- Harry Potter and the Half-Blood Prince (video game) (Mentioned only)
- Harry Potter and the Deathly Hallows
- Harry Potter and the Deathly Hallows: Part 2
- Harry Potter and the Deathly Hallows: Part 2 (video game)
- LEGO Harry Potter: Building the Magical World
- LEGO Harry Potter: Characters of the Magical World
- LEGO Harry Potter: Years 1-4
- LEGO Harry Potter: Years 5-7
- The Wizarding World of Harry Potter
- Harry Potter: Spells
- Harry Potter LEGO Sets
- Harry Potter Trading Card Game
- Harry Potter for Kinect
- Godric Gryffindor's Sword
- Helga Hufflepuff's Cup
- Rowena Ravenclaw's Diadem
- Salazar Slytherin's Locket