| Year | Title | Role | Notes |
| 2003–2004 | The 'Bu | Aaron | 8 episodes; also writer |
| 2005 | Premium Blend | Himself | Episode: "8.4" |
| Arrested Development | Stage Manager | Episode: "Righteous Brothers" |
| House of Cosbys | Cosby Team TriOsby (voice) | 2 episodes |
| 2005–2012 | Saturday Night Live | Various Characters | 139 episodes; also writer |
| 2008 | Human Giant | Jonathan | 4 episodes |
| 2009 | 2009 MTV Movie Awards | Himself (host) | Television special |
| 2009–2011 | American Dad! | Ricky the Raptor / Anti-Christ (voices) | Episode: "Rapture's Delight" |
| 2010 | Freaknik: The Musical | Chad (voice) | Television film |
| The Sarah Silverman Program | Troy Bulletinboard | Episode: "Smellin' of Troy" |
| Parks and Recreation | Carl Lorthner | Episode: "Park Safety" |
| Take Two with Phineas and Ferb | Himself | Episode: "Andy Samberg" |
| 2011–2017 | Adventure Time | Party Pat, Bear, Rap Bear | 3 episodes |
| 2012 | Portlandia | Andy | Episode: "Mixologist" |
| 30 Rock | Himself | Episode: "The Ballad of Kenneth Parcell" |
| SpongeBob SquarePants | Colonel Carper (voice) | Episode: "Hello Bikini Bottom!" |
| Cuckoo | Dale "Cuckoo" Ashbrick | 7 episodes |
| 2012–2016 | Comedy Bang! Bang! | Himself | 5 episodes |
| 2013 | 28th Independent Spirit Awards | Himself (host) | Television special |
| The Awesomes | Various voices | 3 episodes |
| Comedy Central Roast of James Franco | Himself (roaster) | Television special |
| 2013–2021 | Brooklyn Nine-Nine | Jake Peralta | Main role; 153 episodes, also producer |
| 2014 | Saturday Night Live | Himself (host) | Episode: "Andy Samberg/St. Vincent" |
| 2015 | The Eric Andre Show | Eric Andre | Episode: "Pauly D & Rick Springfield" |
| Major Lazer | Dr Nerd/Dr Bass Drop (voice) | 2 episodes |
| 7 Days in Hell | Aaron Williams | Television film; also executive producer |
| 67th Primetime Emmy Awards | Himself (host) | Television special |
| 2016 | Party Over Here | — | Creator and executive producer |
| New Girl | Jake Peralta | Episode: "Homecoming" |
| 2017 | Michael Bolton's Big, Sexy Valentine's Day Special | Kenny G | Television special |
| Master of None | Nicolas Cage (voice) | Episode: "New York, I Love You" |
| Tour de Pharmacy | Marty Hass | Television film; also executive producer |
| Lady Dynamite | Himself | 2 episodes |
| 2018 | Alone Together | — | Executive producer |
| Bob's Burgers | Brett (voice) | Episode: "Sleeping with the Frenemy" |
| 2019 | 76th Golden Globe Awards | Himself (co-host) | Television special |
| PEN15 | — | Executive producer |
| I Think You Should Leave with Tim Robinson | Paul | Episode: "We Used to Watch This at My Old Work"; also executive producer |
| The Unauthorized Bash Brothers Experience | Jose Canseco | Television special; also executive producer |
| The Dark Crystal: Age of Resistance | The Heretic (skekGra) (voice) | 4 episodes |
| 2020 | Mapleworth Murders | Bran BcBillan | 2 episodes |
| Kal Penn Approves This Message | Himself (guest) | Episode: "Kal Penn Approves Voting" |
| 2020–2022 | Never Have I Ever | Himself (voice) | 3 episodes |
| 2021 | Baking It | Himself (host) | 6 episodes |
| 2022 | The Boys Presents: Diabolical | Gary (Reception Guy) (voice) | Episode: "John and Sun-Hee"; also writer |
| 2023 | Mulligan | Prophet Dave (voice) | Episode: "The Easter Egg Hunt" |
| 2023–present | Digman! | Rip Digman (voice) | Main role; also co-creator, writer, and producer |