For 20 years, New York City officials have discussed developing a compost program, and for a decade they have experimented with small-scale versions.

Finally, last month, Mayor Eric Adams launched a citywide initiative to collect food scraps curbside, starting in Queens. Now, with the program scheduled to expand to the five boroughs by the end of next year, city officials will need to figure out what to do with it all.

Officials hope to transform a problem into an asset, creating useful products like fertilizer and energy. The goal is to keep the city’s roughly 8 million pounds of daily residential food waste from rotting in landfills, which produces harmful greenhouse gases, and to save costs on hauling food garbage.

The plan’s success depends on developing local processing capacity not yet in place. And as officials ramp up the logistically complex program, they are working to reuse all the products they derive from the food, instead of sending a small portion to landfill.

The program is called “curbside composting” — but so far, nothing is being composted. The food scraps collected in Queens go to two sites to be “digested” — microorganisms break down most of the material in tanks, creating biogas and a reduced mass of solid, nutrient-rich concentrate that can be used as a fertilizer or soil replacement.

At one of the two sites, the Newtown Creek Wastewater Treatment Plant, food scraps collected from western Queens are mixed with sewage. Once processed, they produce more gas than is needed to heat the plant. A decade ago, officials planned to inject that excess gas into the pipelines of National Grid, but there were years of delays.

On March 31, for the first time, the plant began consistently injecting cleaned and refined gas into the pipelines of National Grid to serve about 2,500 homes.

As the plant processes more food, it could eventually provide enough gas for heat, hot water and stoves in 5,200 homes. This would reduce annual carbon dioxide emissions from burning fossil fuels by more than 90,000 metric tons, the equivalent of removing nearly 19,000 cars from the road, officials said.

“This is an important step,” said Rohit T. Aggarwala, the commissioner of the city’s Department of Environmental Protection, which operates the Newtown Creek facility. “We really need ultimately to have a true circular economy for organics in New York City,” he said.

But not all the products of the digestion process at Newtown Creek are being reused.

Imagine a rotting onion that has been minced and liquefied for processing. Roughly 75 percent of that onion will be transformed into biogas — all used to heat the plant and nearby homes. Some 25 percent of it will break down into a cakey nutrient-rich material — most used productively to replenish soil at agricultural and mining sites. But officials are currently sending about 5 percent of that onion to landfill, potentially as far away as Ohio.

“We can do better,” said Shahana Hanif, a member of the City Council who sponsored a bill that would require separating food scraps, just as New Yorkers must recycle glass, paper, plastic and metal and now also yard waste — though she called reusing 95 percent of food collected “an achievement.”

Officials said by 2030, they will reuse everything digestion produces, as part of the city’s zero-waste plan.

“If you put the banana peel in the garbage, 100 percent of it’s going to landfill,” said Commissioner Aggarwala. “If you put the banana peel in the organics bucket, 5 percent goes to landfill. That’s pretty good.”

New York City has extra challenges in recycling food: more food waste to process, less space to do it in and further distances to travel to access the large tracts of farmland that need quantities of fertilizer.

The city runs a 33-acre compost site on Staten Island, which takes eight or nine months to process food. There, giant piles of food and yard waste sit in carefully tended rows exuding the odor of pine, earthy leaves and rich, ripe rot. The site, which collects food waste mainly from Staten Island schools and street compost bins, produced more than 38,000 bags of compost last year.

The process used at Newtown, anaerobic digestion, can work faster than composting, in a smaller area, while producing energy, which can generate more revenue.

“It works just like a human stomach,” said Jane Gajwani, who is in charge of energy and resource recovery at the Department of Environmental Protection, speaking in front of Newtown Creek’s 145-foot silver digester “eggs.”

Before arriving at Newtown, the food is processed elsewhere by a recycling giant, Waste Management, which filters out contaminants, minces it and adds restaurant grease and liquids like expired milk, creating an “engineered bioslurry” the consistency of crab bisque.

At Newtown Creek, that is combined with sewage and heated in tanks to 98 degrees for about 30 days. This stimulates the growth of bacteria that consume the material, creating methane and carbon dioxide.

For years, Newtown Creek and other city digesters sent the solid byproduct of this process to the Florida citrus groves, to ranch land in Colorado and to agricultural land in Pennsylvania. But that was expensive.

During the 2008 financial crisis, officials decided all of it would go to landfill. Since 2015, officials have been building back a roster of affordable sites that need this fertilizer — new sites must regularly be identified, because fertilizer is not repeatedly reapplied to the same tract of land. Since it contains sewage, there are restrictions on its use.

Both the Departments of Sanitation and Environmental Protection are requesting proposals for processing the food waste the city is collecting. Over the next year and a half, the Department of Sanitation commissioner, Jessica Tisch, said in an interview, officials will be coming up with a viable plan.

Environmental advocates hope that plan will include developing more compost sites like one on Staten Island, now being renovated so that it can process double the yard waste and 20 times more food waste.

It could include food-only digestion facilities, which would produce fertilizers free of the restrictions triggered by sewage. Already, at least one company, Bioenergy Devco, has acquired land to build a food-dedicated digester just outside the city.

The plan could include sending more food scraps long distances for processing, like the food now being collected from eastern Queens. It is sent to a digester 100 miles away at Pine Island Farm in Massachusetts, which uses it to generate heat, electricity, animal bedding and fertilizer.

The plan is likely to involve adapting more of the city’s 14 wastewater treatment plants to accept liquefied food scraps alongside sewage. New technologies could create gas or electricity cheaper than at Newtown Creek, said Commissioner Aggarwala.

In coming years, he said, he would like to also adapt city digesters to produce immediately usable compost-like fertilizer.

“Figuring out how to handle the city’s waste in an environmentally sustainable way has bedeviled officials going back hundreds of years,” said Eric A. Goldstein, a senior attorney at the Natural Resources Defense Council. “We’re on the cusp of a major change.”

In the 1800s, pigs feasted their way through the garbage on Manhattan streets, butchers’ grease produced valuable oils, bone boilers created material for button-making and sugar-refining and the farms of Brooklyn and Queens relied on compost made from the city’s animal and vegetable remains.

Now, as a new crop of cities experiments with recycling food scraps, many are also developing processing infrastructure. Los Angeles began mandatory citywide food recycling in January and is composting all of it. Boston is offering limited curbside pickups of food scraps and both composting and digesting them.

Most U.S. cities that collect food scraps compost them, creating fertilizer. San Francisco and Seattle compost everything and recycle and reuse more material than they send to landfill.

Recently, California cities have been spurred by a state law that requires all municipalities to reduce the amount of organic waste needing disposal by 75 percent by 2025. Municipalities would need to double their composting and digestion capacity to handle the food recycling, according to a 2020 report.

The need to build programs and infrastructure is acute, experts say. Food is the largest portion of the waste stream. Decomposing food emits methane, a greenhouse gas 25 percent more potent than carbon dioxide, and landfills are the country’s third-largest producer of it.

“Getting things out of the landfill is one of the most powerful tools that we have to mitigate the immediate impacts of climate change,” said Kate Kurtz, who is in charge of Seattle’s compost program.

Another concern is returning nutrients to the country’s overworked soil, depleted by fertilizers, intensive farming, deforestation and construction — creating problems like flooding and erosion.

In New York, the city spends more than $400 million a year to move about 14 million tons of garbage to incinerators and landfills as far away as South Carolina.

The city’s Independent Budget Office estimated last year that costs of food scrap collection would rise in the first three years, but with broad participation, would eventually save the city about $33 million a year.

“We just don’t have a lot of infrastructure right now,” said Christine Datz-Romero, the executive director of the Lower East Side Ecology Center, who hopes compost will be a significant part of the city’s plan. “But we can build it.”