A Hat in Time follows Hat Kid, a young alien girl trying to return to her home world via spaceship. While on her journey, she passes over a planet, and a member of the planet’s Mafia comes to collect a toll for the Mafia Town government. When Hat Kid refuses to pay, the Mafia man busts the spaceship door open, causing Hat Kid and all of her “Time Pieces”, magical hourglasses that power her ship, to fall to the planet below. Hat Kid lands in Mafia Town and meets Mustache Girl, a local troublemaker who hates “bad guys”. Mustache Girl agrees to look for the missing Time Pieces in exchange for Hat Kid’s help fighting the Mafia, and the two defeat the Mafia Boss. When Mustache Girl realizes the Time Pieces can rewind time, she wants to use them to become a time-traveling superhero, but Hat Kid refuses due to the dangers of manipulating time. Angered, Mustache Girl declares the two enemies and sets off to find the Time Pieces on her own.
Hat Kid ventures across the planet looking for Time Pieces and encounters many foes, including rival bird directors DJ Grooves and the Conductor competing for a movie award, a malevolent spirit called the Snatcher who steals Hat Kid’s soul, and a group of mountain villagers infected by a dangerous plague, ultimately befriending them all. While Hat Kid is exploring, Mustache Girl breaks into her ship and steals her Time Pieces, using them to turn the planet into a fiery inferno where her word is law. Hat Kid confronts her, but Mustache Girl uses the Time Pieces to open a time rift and make herself all-powerful. The enemies Hat Kid has fought come to her aid in battle, ultimately deciding to destroy themselves so that Hat Kid can use the Pons they drop to power herself up. Hat Kid finally defeats Mustache Girl and uses the Time Pieces to restore the planet to normal and revive all those who were killed. Afterwards, the player can choose whether Hat Kid should hand over a Time Piece to Mustache Girl for protection or not. Though her former foes are sad to see her leave, Hat Kid restores the Time Pieces to her vault and resumes her voyage home.