In one of his final decisions in office this week, President Barack Obama commuted the 35-year prison sentence given to Chelsea Manning, the former Army whistleblower who was convicted in 2013 of giving the media thousands of confidential government documents, some of which revealed Pentagon abuses in Iraq and Afghanistan. The punishment was excessive compared to that of defendants in other cases involving similar leaks of classified information, and after weighing all the factors, Mr. Obama made the wise and compassionate decision to release Ms. Manning, a transgender woman who has already served spent years in the U.S. military's maximum security prison for men at Fort Leavenworth, Kan. The president rightly concluded there's no public benefit to be derived by keeping her behind bars for decades more to come and that justice has already been served.

The president's clemency, as expected, was roundly condemned by GOP critics, who charged that such leniency would encourage people to believe they can leak government secrets with impunity. Perhaps they should spend seven years in Leavenworth and see what they consider lenient. It's also more than a little ironic that President Obama should be accused of laxness in such matters given that his administration has prosecuted more government whistleblowers for mishandling classified information than his 12 predecessors combined.

The comparison of Ms. Manning's leaks and the subsequent dump of classified material by former NSA contractor Edward Snowden remains a topic of much debate. In the eyes of Mr. Obama, Ms. Manning's leaks were embarrassing but not a threat to national security in the same way Mr. Snowden's were; hers were limited to low-level battlefield intelligence in Iraq and Afghanistan as well as diplomatic cables, but his revealed the highly secret means by which the government conducted electronic espionage around the globe. Others see Mr. Snowden as a greater hero in that his leaks exposed government conduct Americans were unaware of and often opposed to, and his disclosures prompted reforms.

What is beyond debate, though, is that Ms. Manning confessed her guilt, cooperated with authorities and made no attempt to flee the consequences of her actions. That's in stark contrast to the behavior of Mr. Snowden, who has sought asylum in Russia to escape being held accountable for his crimes.

Ms. Manning likely made her revelations under severe emotional duress related to her realization that she was transgender, and she has said she was motivated by an act of conscience that drove her to uncover what she believed was a pattern of misconduct among American troops in Iraq and Afghanistan that her fellow citizens should know about. Given those factors and her cooperation, she had no reason to expect the military's unprecedentedly harsh reaction to a crime that normally carries a maximum penalty of 10 years in prison. Her sentence of more than three decades in prison is precisely the sort of miscarriage of justice that the president's power to pardon or commute sentences was meant to address.

Ms. Manning's coming out as a transgender woman and her subsequent requests for the military to allow her to undergo gender reassignment surgery certainly made her continued confinement at Leavenworth problematic and have demonstrated how clueless the military is on issues involving its treatment of transgender people. Ms. Manning spent more than a year in solitary confinement at Fort Leavenworth, twice attempted suicide, and complained bitterly that prison officials didn't know how to deal with her health issues or appreciate the humiliation she experienced as a woman forced to live in a men's military prison. But that was not the reason for Mr. Obama's decision to provide clemency. He didn't even mention it when asked about it in his final news conference on Wednesday. Rather, the president was right to conclude that Ms. Manning has paid her debt to society, that justice has been served and that continuing to confine her serves no useful purpose.