Wang was on an 11-match winning streak, including beating seventh seed Caroline Garcia in the first round, but she was outlasted by Boulter in the New York heat.
In a tight first set, Boulter retrieved an early break, was given a warning for angrily swatting the ball away and had three set points on the Wang serve. But she was unable to convert any of them and Wang promptly broke to wrap up the set.
However Boulter, from Leicester, cleared her head impressively and dominated the second set to level the match. Having broken again for 5-4 in the decider she suffered a horrible wobble, throwing in two double faults in the first three points.
But once again Boulter recovered her composure and wrapped up a fine win when Wang hit the net.
Boulter will face 21-year-old American Peyton Stearns, the world number 59, in what looks a very favourable draw, for a place in the last 16.
“I’m obviously super happy, the start of the match I was a little bit nervous,” Boulter said.
“Finishing it was I a little bit nervous as well. I’m really proud of myself the way I handled it and I managed to get over the line.”
There was more good news for the Brits as Jack Draper produced a sensational display to beat Hubert Hurkacz in straight sets and join Boulter in the third round.
The 21-year-old has been hampered by injuries this year but showed what he can do when fitness is not an issue, as he dominated 17th seed Hurkacz in a 6-2 6-4 7-5 victory.
Jodie Burrage meanwhile was unable to pull off a major shock, as second seed Aryna Sabalenka eased to a 6-3 6-2 win.
While Andy Murray was also knocked out as he fell to defeat against Grigor Dimitrov, Cam Norrie enjoyed a more successful time on court as he beat Yu Hsiou Hsu in straight sets.
Norrie had to save three set points before taking the opener, but did not look back from there in the 7-5 6-4 6-4 victory in two and a half hours.
Additional reporting by PA Sport.