What hero can counter Viper best? We're talking about 1v1 middle lane (or any lane).
First off, 1v1 mid lane is different from 1v1 top or bottom for 3 key reasons.
In 1v1 mid, there is a high and low ground, which means lane control is very important. If you are constantly attack uphill, you will miss 25% of the time and that will screw up your laning phase. Then there is also rune control. As a mid hero, you have the ability to access both the top and bottom runes, which can greatly change the pace of the game. Lastly, the top and bottom lanes allow creeps to be pulled. That can also change the laning phase.
When playing mid against Viper, there are many ways to play against it. Viper is naturally a very strong 1v1 laner, so most of the time, you have to decide whether you want to safely farm a lane without dying, or you want to sacrifice farm in terms of creep kills in order to kill viper. In this case, since you asked for the best counter, I will provide heros that are able to both farm the lane and able to kill viper.
But before that, we need to talk about understanding the matchup. There are two key components to 1v1 laning: Understanding the heros and the person's technical ability. Technical ability refers to one's ability to last hit, deny, and control the lane / runes. You want to be last hitting as much as possible, and pushing the lanes before the runes spawns @ every two minutes. Ideally, if you have one ward covering a rune spot, you want to clear the entire enemy wave by 2:00x minutes in order to get one of the runes. If you clear the wave and the enemy hero still wants to contest the rune, he is losing valuable exp and potential gold.
Understanding the heros and matchup is a little bit different though. You can have far inferior technical skill, but still win the lane by simply understanding the matchup better. By this, I mean killing the enemy hero. As long as you can always kill the hero, then he can't farm or get experience. And while you don't get as much farm as constantly last hitting creeps, you suppress the enemy hero while you get ahead in EXP and can control the mid game better.
So now let's talk about heroes that will be favorably against viper mid. This means a hero that should be winning the lane in terms of both CS and kills. For the sake of this answer, we are going to assume this is an actual 5v5 game and not just a 1v1 matchup, so heros like abaddon will be excluded. Therefore, we will also only consider the 1v1 match up until the 6 minute mark because afterwards, lanes tend to break up and go accordingly to what each team needs.
The first thing to know is that no melee hero can consistently farm well and kill or zone viper out of lane. Instead, what we want to pick is either a hero with some sort of spammable aoe skill, to push the lane before the even minute mark and control the runes, or pick someone that straight up beats viper in a dog fight so you can successfully kill him or zone him out of lane.
Sniper - Skill headshot and take aim early. You will out range viper, which means you can get free pot shots on him, then run away so he can't attack you back. If you proc the headshot, you will do considerable amounts of damage to him , forcing him to stay relatively back. While you do less damage than viper, you can still farm the lane by zoning him out. Make sure to harass him when none of his creeps are low , so you can still harass him and get creep kills when you are not harassing.
Lone druid - This hero pretty much wins every 1v1 matchup due to having a tanky bear. Have the bear attack viper while you last hit. Once you hit level 5, if you get a lucky entangle, you might even be able to kill the viper. Either way, the bear zones the viper out of the lane.
Razor - Static Link is the key. Absorb all of viper's damage, and see if he dares to fight you. He will do no damage while you can just right click him down, with the help of the plasma field. Ofcourse, you still max plasma field first and utilize it for both killing viper and rune control (explained below).
Weaver - Shikuchi is hard to beat. Also have at least 1 point in swarm when you are level 4+. If viper is ever caught out of position and you are full HP as weaver, you can easily kill him. Whether he is very far away from his tower middle, or approaching rune, all you have to do is swarm him, shikuchi him, and right click him down. Viper has very limited movement against a weaver.
Puck,Storm,Windrunner,Deathprophet,Pugna,Leshrac,Qop - Don't engage in man fights with Viper. He will beat you. Instead, try to stay a bit back from the creep wave and get last hits / denies. Whittle him down with your spells while taking minimal damage. When the even minute is about to approach, start spamming the wave with your spells. Clear the entire wave before the even minute mark so you can control the runes. Use rune leverage and bottle refill to win the lane. Viper won't be able to sustain your spell harass on him when you are characters like Windrunner, Deathprophet, Lesh, Qop. Sure you might need to take a couple of right clicks from viper, but by controlling the runes, you have bottle refills to replenish that HP/Mana lost and he doesn't. Then when you get a really good rune, take advantage of it.
Tinker 1 - Skill up laser and rockets. Since laser is pure damage, Viper should be easily nuked down. Just get your fast bottle and start nuking him down.
Tinker 2 - Skill up march laser. Use march before the even minute marks to control runes. Use laser as both a damage skill and a way to make viper miss.
Outworld destroyer - Skill up astral imprisonment and essence aura from levels 1-8. That means skip your ult, unless your ult can net you a kill. Use astral imprisonment before viper wants to last hit a creep. Then astral him, and deny that creep. Viper also can't man fight you when you have stolen a lot of his int. In the case of a man fight, you will just chunk away his HP. And if you need to run, just astral him.
Batrider - Bat is a hero similar to weaver. If Viper is ever out of position, as in far away from the tower. And you have 4 stacks of stick napalm on him, he is pretty dead. All you have to do is firefly and run him over, while still stacking more sticky napalms and adding in some right clicks. As long as you don't tank tower damage, and you both are starting at the same HP (and less than a 2 level difference between heros), you will always kill him solo.
Needless to say, these heros will win the matchup when the player has a good understanding of how both his own hero and Viper works middle. If both players are of equal skill level and aren't new to dota, these heros will naturally win. They don't win when the Viper has a better understanding of how to play and react against your hero, or if the skill difference is too huge. Sometimes, there is that one guy mid who can hit 35 creep kills and 15 denies in 6 minutes time. In that case, you just have to try to kill him, because you know you don't have better technical skill than him. Either that, or you start moving around the map and help your other lanes win (sometimes wait for level 6, sometimes not).
Silencer - Viper's Orb does not count as a spell and so he is completely vulnerable to both Silencer's Q and E.
Windrunner - When Viper tries to straight up fight you, you can Windrun to win the fight or get some free damage. It also gets you out of bad situations without taking additional damage.
Death Prophet - Viper has no real counterpush, so by spamming down waves with Death Prophet or a variety of other similar ranged heroes (Queen of Pain, Leshrac, Puck), you can have free rune control.
These all being high ranged heroes is key, because Viper does very well against melee heroes due to his strong harass.