A six-time singles champion at Flushing Meadows, Williams has not played since suffering the injury at Wimbledon in June.
She was forced to retire from her opening-round match against Aliaksandra Sasnovich after slipping on a wet Centre Court surface at the All England Club.
Williams pulled out of last week’s Western & Southern Open in Cincinnati in order to focus on her rehabilitation but she failed to recover in time for the final Grand Slam of the year.
Williams wrote on Instagram: “After careful consideration and following the advice of my doctors and medical team, I have decided to withdraw from the US Open to allow my body to heal completely from a torn hamstring.
“New York is one of the most exciting cities in the world and one of my favourite places to play – I’ll miss seeing the fans but will be cheering everyone on from afar.
“Thank you for your continued support and love. I’ll see you soon.”
Williams is the latest big name to pull out of the tournament after reigning men’s champion Dominic Thiem, four-times winner Rafael Nadal and British No 3 Kyle Edmund all withdrew due to injury.