The 39 year old, who carried Sweden’s flag at the Olympics Opening Ceremony in Rio, told Dagens Nyheter a recurring back problem had made it difficult for her to compete at her maximum level.
“Then it's no longer as fun and when I feel it is time to stop,” she said.
“The decision has emerged gradually. In the autumn I’ve trained less than usual and had weekends off for the first time. Now I understand, for example, for the first time what people mean when they talk about how great Friday evenings are.”
She described her career coming to an end as “both beautiful and terrifying”.
She competed in six Olympic Games, a record for a female swimmer, but an Olympic Gold medal eluded her.
However, with 25 European golds, 12 World Championship golds and two Olympic silver medals, Alshammar is one of Sweden's most decorated swimmers in history.