FORTUNE — Two years ago, comedian Joey Diaz had little to laugh about. The then 53-year-old Diaz was opening for younger comedians, struggling to land acting gigs, and considering a career switch.
But after releasing his work online, Diaz, a comic best known for bit roles in NBC’s “My Name is Earl” and the Adam Sandler film “The Longest Yard,” has revitalized his career. Soon after uploading his hour-long special “It’s Either You or the Priest” online, Diaz attracted the attention of the Cartoon Network, which cast him as a recurring character on “Children’s Hospital.” Other TV and film roles followed, including a part in “Raging Bull II.” In May he headlined a sold-out, three-city comedy tour.
Diaz is part of a growing circle of stand-up comedians—from household names to people just starting out — who are using the web to build their audiences and claim a bigger slice of sales. While sketch comedy found the web years ago — think “Lazy Sunday” and other digital shorts — stand-up comedians are catching on, moving their bits online and selling directly to viewers. In the process, they’re upending the way that audiences find talent, and stand-ups become stars.
MORE: The major crisis in TV
Since the earliest days of television, stand-up comedians have weathered a long and often painful road to stardom: performing for free in obscure clubs, before earning paid gigs, then opening for Leno or Letterman, and in the rarest of cases, reaching the holy grail of stand-up success: a prime-time special on a network like HBO. They’d earn a six-figure advance for the show, followed by royalties from DVD sales and eventually, iTunes downloads.
But today that path is changing, and not just for comedians trying to break in to the business. Last December, comedian Louis C.K. bypassed traditional networks and released his special, “Live at the Beacon Theater,” on his personal website, charging $5 per download.
At the time, C.K called his decision “an interesting experiment” that allowed more fans to see his shtick. They could download and watch the special whenever they wanted, rather than view it once on a network like Comedy Central.
But the experiment worked— big time. In two months C.K. brought in over $1 million online—the equivalent of 220,000 downloads— netting $750,000 on a show that cost $250,000 to produce. (He also earned an undisclosed payout in ticket sales for the live event in New York.) This week he announced that he’s selling tickets to his upcoming, 39-city tour directly through his website, cutting out Ticketmaster in the process.
Jim Gaffigan, another stand-up star, is also targeting his audience online. In April Gaffigan debuted his hour-long special, “Mr. Universe,” on his website, rather than sell the broadcast rights to HBO or Showtime. Gaffigan won’t disclose sales, but says that in two months he’s already out-earned what we would have made from a traditional network TV contract. He also sold the broadcast rights to Netflix NFLX , which allows viewers to stream the show online.
The secret, for Gaffigan and others, is scale. After covering production costs and paying for a website with a download service, comedians receive every cent of revenue they earn from an online show (less a minimal fee to PayPal). Since they keep a bigger cut of sales, they can charge less for every download—usually $5 on a personal website. The most bankable stars can double-dip, selling broadcast rights to a network like Showtime at a reduced rate at a later date. They can also sell the material on iTunes, keeping $3.50 of every $10 download.
Comedians can also push creative boundaries online, where they’re outside the domain of the FCC. Darcy Michael, who released his half-hour long album “One Skinny Bitch” on his personal website in May, says that his material would have been completely different if it aired on TV.
“I swear like a trooper,” says Michael. “They’d take half of that out.”
But what comedians gain in edgy material, they lose in promotion from deep-pocketed TV networks. In the early days of his career, says Jim Gaffigan, a Comedy Central special was “an infomercial for my brand of comedy.”
For comedians who don’t have the luxury of a paid TV gig, the web offers a way to break out, at a manageable expense. Darcy Michael spent just $4,000 to produce “One Skinny Bitch.” Comedian Rob Delaney’s first online special, due online in August, cost $30,000 to produce. Robust online sales could help both comedians edge closer to paid TV work.
Neither industry experts nor comedians envision a world where the web will entirely replace a one-hour TV special. More likely, says Sam Ford, an expert on digital distribution, is a model where talent generates buzz online, and then attracts the attention of networks. Through their promotional power, the networks then build a comedian’s fan base until the comedian can return to releasing work on the web— this time, for a profit.