It’s tough being a terrapin in Queens.

If raccoons don’t raid their nests, other predators snatch hatchlings as they take their first steps.

But for the first time, the city is helping give some diamondback terrapins at Idlewild Park in Queens a fighting chance.

The Parks Department and local volunteers set up protective cages around 27 nests a few weeks ago and have been monitoring them since. Each nest holds between seven and 13 eggs.

The first of the hatchlings appeared Tuesday to the delight of Ellen Pehek, principal research ecologist at the Parks Department’s Natural Resources Group. Pehek said cages have been successful at keeping out the hungry raccoons, despite the masked bandits’ efforts to dig under them.

High school volunteers cut small holes in the cages so the hatchlings can crawl out.

“We think we have quite a few little babies getting ready to come out and help the population,” Pehek said.

A crew of Parks employees and volunteers from the Eastern Queens Alliance will move the tiny terrapins — not much larger than a silver dollar — to safer sites in the park.

“We want to help them get to some cover vegetation,” said Pehek. “Crows and gulls can be a problem. Sometimes the hatchlings spend winter on land, burrowing under the vegetation and don’t go into the water until next year.”

Terrapins, the primary ingredient in once-popular turtle soup, have plummeted in number over the past century due to overharvesting. The population remains relatively strong in the Jamaica Bay area, where they are often seen crawling across the runways of JFK Airport.

But the state Department of Environmental Conservation wants to stop legal harvesting of the diamondback terrapin noting “a single season of intensive harvesting has the potential to endanger this species in New York.”

Terrapins also face other man-made hazards, such as drowning in crab traps and pollution.

“They are part of the whole salt marsh ecosystem,” Pehek said. “They eat mud snails and other snails that would otherwise overpopulate and consume the marsh grasses, which help buffer storm surges. They keep the marsh going.”