Cowboy Episode

An Out-of-Genre Experience when a series other than The Western picks up a six-shooter, dons a Stetson and rides off into the sunset. In other words, a non-Western temporarily becomes a Western (or at least a pastiche thereof).

This can be done through Time Travel, virtual reality, a Dream Sequence or, for works set in the right period but wrong location, a trip out West. The effect can also be achieved with a Fantasy Counterpart Culture.

Anime and Manga

 * Cowboy Bebop had one; while the main character is a "cowboy" (i.e., a bounty hunter), one episode had Spike face off against a cowboy cowboy, complete with hat, revolver, horse, lasso and everything.
 * Done in the Tenchi Muyo adaptation, Tenchi in Space. After Tenchi's been kidnapped by the bounty hunter bent on defeating Ryoko, the two agree to meet at a location suspiciously similar to a small western town, complete with tumbleweed, saloons, and an eerie sunset. Whether Tenchi's status as the male version of the Bound and Gagged Damsel in Distress is Played for Drama or Played for Laughs generally depends on the viewer's opinion.
 * Washu actually created the western town specifically for the duel to to inovke the trope. She seemed pretty proud of it.
 * Speaking of Tenchi Muyo: Its spinoff Magical Project S has one episode featuring a Wild West theme park in competition with a ninja theme park.

Comic Books

 * Tintin in America was based on European stereotypes of the USA and features plenty of Wild West imagery despite being set in the 1930s.
 * Justice League of America #198-199 has four amnesiac superheroes (Elongated Man, The Flash, Green Lantern and Zatanna) being dumped in the Wild West.

Film

 * Back to the Future Part III is mostly set in the Old West, and while dealing with the characters' various attempts to get back to the future plays with many of the genre's stock characters and situations.

Literature

 * The A to Z Mysteries book The Ninth Nugget takes place on a dude ranch.

Live Action TV

 * Batman: The two-part "Come Back, Shame"/"It's How You Play The Game" featuring Western-themed bad guy Shame.
 * The Brady Bunch had a dude ranch episode.
 * The second paintball episode of Community starts off with a very western feel.
 * "Paradigms of Human Memory" showed that the study group went to an authentic Wild West ghost town.
 * The Dick Van Dyke Show: Rob gets knocked out for a dental procedure while worried about a sketch Alan Brady wants for the show. He dreams he's a wild west sheriff and Alan is "Big Bad Brady," a local outlaw who calls him out for a Showdown At High Noon. After he wakes up he realizes it's perfect for the sketch, and asks his dentist to put him out for Just Five More Minutes so he can remember what he dreamt.
 * The Doctor Who serial The Gunfighters. The Doctor and his companions travel to the Old West shortly before the gunfight at the O.K. Corral.
 * On Family Matters, Carl dreams he's a sheriff in the Old West who has killed the father of the town's most annoying gunslinger, "Two-Gun" Urkel.
 * Gilligan's Island had an episode ("The Sweepstakes") where Mr. Howell dreamt he was prospector in the old west.
 * The Goodies: "Bunfight at the OK Tearooms"
 * Happy Days had a dude ranch episode.
 * MacGyver: Has two Wild West dream episodes, "MacGyver's Women", when MacGyver dreams that he's in the Wild West and has to defend three women from outlaws, and "Serenity".
 * Matlock had an episode called "The Nightmare", in which the show's title character gets knocked out and finds himself in a Wild West setting.
 * Midsomer Murders: "Blood on the Saddle"
 * Mighty Morphin Power Rangers had the episode "Wild West Rangers" where Kimberly is sent back to 1880 during Angel Grove's Wild West era.
 * Modern Family's third season opener was a dude ranch episode.
 * My Favorite Martian used Time Travel in the two-part "Go West, Young Martian".
 * The Prisoner episode "Living in Harmony" takes place in a Wild West setting. Number Six is a sheriff who turns in his badge and gun and tries to leave town.
 * An episode of Psych had Shawn and Gus investigating a murder in an old-west theme park. They, of course, dress up in cowboy clothes and start playing Sheriff...the whole episode them because an exploration of various old-west tropes, even a By Wall That Is Holey example.
 * Red Dwarf: The episode "Gunmen of the Apocalypse" involves the characters entering a virtual Western town that serves as a metaphor for Kryten's struggles with computer virus. The episode even ends with Starbug flying off into the sunset.
 * Star Trek has several:
 * Star Trek the Original Series has "Spectre of the Gun", in which the main characters are forced to re-enact the gunfight at the O.K. Corral on an alien world.
 * Star Trek the Next Generation has "A Fistful of Datas" where a holodeck simulation of the Old West goes wrong.
 * Star Trek Enterprise has "North Star", featuring a planet populated by the descendants of settlers who had been kidnapped by aliens in the 1860s.
 * Supernatural episode “Frontierland”. Sam and Dean go back in time to Old West Wyoming, get a magical gun from Samuel Colt, have a High Noon moment with a phoenix, and return to the present still dressed in cowboy paraphernalia (which Dean very likely kept, as he has “a fetish” for western wear).
 * Unhappily Ever After did a Western episode that lampshaded the fact that this type of episode often takes place entirely in one saloon: "This was a one-set town."

Newspaper Comics

 * Modesty Blaise: The "Butch Cassidy Rides Again!" arc.

Western Animation

 * Avatar: The Last Airbender: "Zuko Alone" has a very western feel, with the classic plot of a mysterious stranger helping a town in need.
 * In Codename: Kids Next Door, one episode is set on a school bus as homework bandits invade and rob the kids on board at (pop)gunpoint. The main characters are on this bus and have to stop the bandits before the bus reaches the school.
 * Timmy Turner in The Fairly Odd Parents goes back in time to the founding of the city of Dimmsdale. As Dimmsdale is in southeastern California and the city was founded in the mid-19th century, Dimmsdale is depicted as a Wild West town.
 * Futurama: The episode "Where the Buggalo Roam" is a Western parody set on Mars, including Martians who closely resemble American Indians.
 * Quite a number of Garfield and Friends shorts had Jon, Garfield and Odie visit the local dude ranch Polecat Flats, run by their cowboy friend Cactus Jake.
 * Jackie Chan Adventures has an episode about identical relatives of the main cast living in the Old West.
 * The syndicated series of The Jetsons (the series with Orbitty) had an episode titled "Dude Planet".
 * Justice League Unlimited has one in which the Trinity is sent back to the Old West.
 * Legion of Super Heroes episode "Unnatural Alliances".
 * My Little Pony Friendship Is Magic features the episode "Over a Barrel", in which the cast come to Appleloosa to deliver a tree, and end up resolving a conflict between the resident ponies and the buffalo tribe.
 * "The Last Roundup" from Season 2 also features a decidedly Old West setting.
 * Phineas and Ferb don't go to the Old West, but they go cowboy in at least two episodes:
 * One episode involving a robot rodeo.
 * One episode involving a cattle drive at the mall.
 * The Powerpuff Girls has an episode that is basically a normal episode of the show, but in the Old West. The girls become the Steamypuff Girls.
 * Episode XXIX of Samurai Jack is set on a train, where Jack is pursued by a (married) couple of bounty hunters.
 * The Simpsons has had a few, like "Dude, Where's My Ranch?"
 * The SpongeBob SquarePants episode "Pest of the West".
 * Hanna-Barbera's The Little Rascals episode "Showdown at the Rascal Corral" wasn't set in the Old West as such, but Alfalfa did play cowboy.
 * Codename: Kids Next Door: "Operation: M.E.S.S.A.G.E." is packed full of Western tropes with Numbuh 2's attempt to deliver fourth grade president's message being played like a Pony Express Rider crossing hostile territory.
 * Squirrel Boy: "Gumfight at the S'Okay Corral"
 * The Brady Kids had two: "Long Gone Silver" (guest-starring The Lone Ranger) and "Give Me a Home Where the Panda Bears Roam and the Dog and the Mynah Bird Play".