Ex-convicts were saddled with $20 million in court fees straight out the slammer in 2017 — with some getting jailed again for failing to pay the fines, according to a report released Tuesday.

The analysis by city Comptroller Scott Stringer found that not only did 45 percent of the newly released start out in the hole that year, they were slapped with more than 100,000 civil judgments and 11,000 warrants for their unpaid debts.

“It makes zero sense to me that when we have people who have already been sentenced, who paid a fine, who are already serving time, that we would lay on these surcharges, which means basically they can never come out of poverty,” Stringer said at a press conference.

Mandatory court surcharges — which run as much as $375 — are imposed upon sentencing, though Stringer’s report says the vast majority of the fees are for non-criminal violations and non-DUI traffic offenses.

And when former inmates can’t pay, they face even more jail time. In 2017, there were 161 cases of defendants ordered immediately incarcerated for nonpayment, the report found.

“It’s a money pit that people can’t get out of,” he said.

Stringer, who is eyeing a run for mayor in 2021, blasted private companies for “hiding behind the curtain and raking in huge profits off service and convenience fees,” including $12 for money transfers, 33 cents for an electronic stamp to send an email and $2 to $3 “convenience fees” for electronic transfers.

Parolees are also expected to cough up $30 a month in supervision fees upon release — and the company that is authorized to collect the cash charges an extra fee.

“Folks, this is big business!” said Stringer, saying the debt hurts defendants from low-income communities and affects their credit ratings and ability to find work post-incarceration.

Stringer proposed nixing mandatory court surcharges, wiping out outstanding court debt, ending driver license suspensions for unpaid fines, and doing away with locking people back up over unpaid court debt. He also wants to end probation and parole fees.

The comptroller called on Mayor Bill de Blasio to work with him to convince Albany legislators to help straighten out the court system, adding “so many people, so many people of color living in this city are victimized financially every single day.

Stringer’s report comes as the city pushes to close Rikers Island jail and replace it with four smaller lockups in Manhattan, Brooklyn, Queens and the Bronx.