Sans is a major character in Undertale. He and his brother Papyrus are both sentries living in Snowdin, a frigid settlement of monsters located near the Ruins of the monsters' original capital city. The player character first encounters Sans after escaping the Ruins, who immediately reveals his complete lack of interest in fighting humans. Instead Sans asks the player to humor Papyrus, his overzealous and slow-witted brother, by interacting with Papyrus' ill-conceived attempts to confound and capture a real human.
Sans reappears in different locations throughout the course of the game, sometimes as an NPC merchant. Depending upon the player's moral choices, Sans' dialogue can change drastically between different playthroughs, and he may even disappear entirely until the endgame. Along with Flowey, Sans will occasionally break the fourth wall to acknowledge the player's actions prior to reloading a save or resetting the game world, hinting at a deeper understanding of the malleability of time than most of Undertale's other characters.
Near the end of the game, Sans confronts players in New Home's "Last Corridor" area to render his judgement based upon the player character's accrued "EXP" and current "LV". He explains the true nature of EXP as an acronym for "EXecution Points," and its direct correlation to the player's LV; also known as "LOVE," or "Level Of ViolencE". If the player refrained from killing any monsters, thus earning no EXP, Sans will express his appreciation regarding the player's compassion. Sans goes on to acknowledge that the fate of all monsters now rests entirely in the player character's hands, admitting that the player faces a difficult choice regarding their impending battle with King Asgore.
During a "genocide" playthrough, Sans serves as Undertale's final boss in lieu of fighting Asgore and Flowey. Despite his laid-back characterization, the battle against Sans is by far the most difficult in the game; it is also the only encounter in which the enemy acts prior to the player's first turn. This fight features a variety of rapid bullet hell-style attacks and quickly-changing soul modes that demand superior reaction times and pattern memorization. Sans' attacks also inflict a unique poison-like status effect called "KR," or "Karmic Retribution," which slowly drains players' HP and nullifies the invincibility frames that normally temporarily prevent further damage to the player's SOUL after being hit. Although Sans only has 1 HP himself, the player's own attacks will consistently miss thanks to Sans' uncanny ability to dodge.
Players that manage to survive Sans' onslaught will eventually witness his "special attack," which turns out to be Sans simply doing nothing during his own turn. By Sans' reckoning, so long as he does not act in battle, the encounter will never end and the player will be trapped until they eventually abandon their genocidal quest out of frustration. However, Sans eventually falls asleep during his turn, allowing the player's SOUL to push against the edges of the bullet box and move the box across the screen. The player can then attack Sans by pushing the bullet box to overlap with the "FIGHT" button at the bottom-left corner of the screen. Although Sans once again dodges the first attack, the player character will automatically attack a second time and successfully deal damage against Sans, ending the battle.