Taylor, who plays county cricket for Nottinghamshire, withdrew from last week's game against Cambridge MCCU with what was believed to be a viral infection.
However, scans revealed he has a serious heart condition known as Arrhythmogenic Right Ventricular Arrhythmia (ARVC).
Taylor said on his Twitter account.
Safe to say this has been the toughest week of my life! My world is upside down. But I'm here to stay and I'm battling on! #lifestooshort ????- James Taylor (@jamestaylor20) April 12, 2016
The middle order batsman played seven test matches and 27 one-day internationals for England and captained the side against Ireland in May last year.
"It is both shocking and saddening to hear that James' career has been cut short in such a sudden and unexpected manner," England team director Andrew Strauss said in a statement released by the ECB.
"Throughout his career, he has constantly impressed with his determination to make the absolute most of his ability, and it is immensely cruel that such a hard working player will be unable to fulfil his great potential in the international arena.
"The ECB will work closely with Nottinghamshire and together we will do everything possible to help James through this difficult period, and aid him in his recovery."