Beyonce has revealed that she wrote the "saddest song" of her life after she suffered her miscarriage.

The award-winning singer and actress, who is mum to one-year-old daughter Blue Ivy, has opened up about the sad experience in her HBO documentary Life Is But A Dream, reported E! Online.

"About two years ago, I was pregnant for the first time. And I heard the heartbeat, which was the most beautiful music I ever heard in my life," the 31-year-old said.

"I picked out names. I envisioned what my child would look like... I was feeling very maternal," she continued, adding that something went wrong early in the pregnancy, which she only found out about during a routine doctor's appointment.

The news about the miscarriage was revealed by her rapper husband Jay-Z in his song Glory.

Beyonce added: "I flew back to New York to get my check-up - and no heartbeat. Literally the week before I went to the doctor, everything was fine, but there was no heartbeat."

The experience inspired her to pen a new track.

"I went into the studio and wrote the saddest song I've ever written in my life. And it was actually the first song I wrote for my album," she said, without naming the track or even revealing if it made the final cut.

"And it was the best form of therapy for me, because it was the saddest thing I've ever been through."