WASHINGTON -- All hogs in Massachusetts will be able to stretch their legs and turn around in their crates and all hens will be able to spread their wings under a law passed in November by voters in the state.

Laws like this one, which strictly regulate how farm animals are confined, are becoming more common across the U.S., as large-scale farming replaces family farms and consumers learn more about what happens behind barn doors. Massachusetts is the 12th state to ban the use of some livestock- and poultry-raising cages or crates, such as gestation crates for sows, veal crates for calves or battery cages for chickens, which critics say abusively restrict the animals' movement.

The restrictive laws have taken hold so far in states that have relatively small agriculture industries for animals and animal products and fewer large-scale farming operations. But producers in big farming states see the writing on the wall. Backed by state farm bureaus, large-scale industrial farmers are pushing for changes that would make it harder for states to further regulate the way they do business.

North Dakota and Missouri adopted amendments in the last few years that enshrined into their constitutions the right of farmers and ranchers to use current practices and technology. Legislatures in many states, including Indiana, Mississippi, Nebraska and West Virginia, considered proposed amendments this year. And Oklahoma voters rejected a similar amendment sent to them by the Legislature in November.

Farmers acknowledge that some people who do not spend much time on farms may object to some of their practices. But they say that they do not abuse animals and that their practices are the most efficient and safest way to keep up with demand for food. And, they say, complying with restrictions on raising poultry and livestock like those approved in Massachusetts are costly for them and for consumers.

They point to an 18 percent increase in the price of eggs _ about 49 cents a dozen _ in California last year that was attributed to a law that created strict space requirements for hens. The law applies not just to producers in the state but to producers in other states that sell eggs there.

"Our nation's ability to protect its food supply can be threatened by unnecessary regulations driven by activist agendas, often by people who've never set foot on farmland or have no idea what it takes to produce a crop," said Paul Schlegel, director of environment and energy policy for the American Farm Bureau Federation.

Right-to-farm laws were put in place by all 50 states starting in the 1970s, as suburban development sprawled to rural areas. The laws were intended to protect farm owners from lawsuits brought by new neighbors who claimed the farms _ with their smells, sounds and chemicals _ were a nuisance. The newly proposed amendments would extend the protections by locking in farmers' ability to use modern technology and practices.

Animal welfare advocates, such as Daisy Freund, director of farm animal welfare for the American Society for the Prevention of Cruelty to Animals, say the modern practices are not humane and call the right-to-farm amendments "right to harm" laws.

The amendments would not only prevent states from passing new animal treatment laws, but would make it harder for anyone to win a lawsuit against an agriculture business, even if the operation was affecting nearby quality of life, or air or water quality, Freund said.

Matthew Dominguez, a former lobbyist at the Humane Society of the United States who now works a national advocacy organization called the Nonhuman Rights Project, said the legislators who are proposing the amendments _ including some who have received hefty donations from the industry _ are trying to find any way they can to continue agriculture business as usual.

But consumer expectations already are forcing producers to change how they operate, said Josh Balk, vice president of farm animal protection at the Humane Society of the U.S. Demand for free-range eggs and grass-fed beef is growing, pushing large companies to change their standards. Wal-Mart and McDonald's recently committed to using only suppliers that raise cage-free hens by 2025.

Market demands will force producers to change their practices or be left behind, Balk said. The U.S. Department of Agriculture projects that to meet demand, the industry will have to convert over half its egg production to cage-free systems by 2025, up from the current rate of 10 percent.

"It's kind of similar to which companies are trying to still produce black and white TVs, and which ones are selling color TVs," Balk said.

Consumer expectations have shifted as animal welfare groups such as the Humane Society have used undercover investigations to expose industry practices.

Videos and images published on the advocacy groups' websites, on YouTube and in documentaries depict windowless warehouses with hundreds of sows confined in gestation crates, where they spend most of their lives. Hens are shown in cages as wide and long as a letter-sized piece of paper, and barely tall enough for them to stand in.

Many of these methods are accepted by industry groups such as the United Egg Producers and the National Pork Producers Council. Farmers say keeping animals in cages is the most sanitary and safest way to care for large groups of farm animals. And farming groups say the practices encouraged by animal welfare groups might not make life for farm animals any better.

The National Association of Egg Farmers said that while Massachusetts voters will pay more for eggs, the lives of chickens will not improve. Caging chickens, the association said, reduces the likelihood they will become diseased. It also improves the quality of eggs, the group said, by reducing the chance that the eggs touch manure.

Farmers and ranchers aren't opposed to regulation that protects "the environment, that protects the food supply and that protects our families," said Tom Buchanan, president of the Oklahoma Farm Bureau. "We buy our food from the same shelves you do," he said.

But Buchanan and others, such as Harry Kaiser, a professor at the Charles H. Dyson School of Applied Economics and Management at Cornell University, say consumers should have the option of buying meat and eggs without paying a premium for special animal treatment.

Kaiser led the study, funded by the National Pork Producers Association, that showed an 18 percent increase in the price of eggs in California. The price increased even more than that because of a bird flu crisis, but that additional increase was filtered out of the study's results.

Kaiser said the results didn't surprise him. If businesses aren't able to use the most efficient methods for producing eggs, he said, their costs will go up.

Not everyone can afford to pay premium prices, he said, and others don't want to.

Rodolfo Nayga, professor in the department of agricultural economics and agribusiness at the University of Arkansas, has found that while a segment of the population is willing to pay higher prices for organic food, or food produced using higher standards for animal treatment, not everyone is.

"This isn't for everybody," Nayga said. "There are some farmers that won't be able to accommodate the regulations for animal welfare and for environmental concerns."

When animal welfare groups started about a decade ago to pay their employees to take jobs on farms to expose practices, the industry responded by pushing for what animal welfare advocates call ag-gag laws. Some of the laws made it a crime to take photos or videos of private farm property without the owner's permission, while others made it a crime for an employee of an animal welfare organization to lie about where they worked when they applied for a job on a farm.

About 26 states considered ag-gag laws from 2010 to 2015, but only nine _ Idaho, Iowa, Kansas, Missouri, Montana, North Carolina, North Dakota, Utah and Wyoming _ passed them.

The Humane Society is not aware of any ag-gag bills proposed this year. Interest in these laws has faded after they faced opposition from animal welfare groups, as well as groups advocating for food safety, freedom of speech and workers' rights, said Dominguez, who traveled the country fighting the laws for the Humane Society. Lawmakers also may be hesitant to propose the laws when so many are being challenged in court, he said.

Idaho's ag-gag law was overturned last year by a U.S. district judge who said it suppressed freedom of speech and violated the Equal Protection Clause. Lawsuits are pending in North Carolina, Wyoming and Utah.

Six states _ Alabama, Iowa, Kentucky, Missouri, Nebraska and Oklahoma _ filed suit against California for its anti-confinement egg law, which was approved by voters in 2008 and took effect last year.

The states said the law put their egg producers that supply California at a disadvantage, requiring them to either stop selling eggs in California or spend hundreds of millions of dollars to comply with the California law, which would increase prices even at home.

The 9th U.S. Circuit Court of Appeals ruled in November that the farming states had no legal right to challenge California's law, upholding a lower court's decision to dismiss the case.

Updates to right-to-farm laws have seen some success, but not everyone thinks they are the way to go.

In Oklahoma, small farmers worried that the proposed constitutional amendment would prevent them from suing larger producers whose practices damage their business. It took years for the Oklahoma Farm Bureau to get the measure on the state's ballot, only to see it overwhelmingly defeated.

The amendment was meant to prevent the Legislature from passing the same type of law Massachusetts approved, one that would "drastically handcuff and handicap farmers and ranchers, which ultimately results in less food and higher prices," Buchanan said.

Although Oklahoma is a traditional farming state, Buchanan fears that as more people move to cities and away from rural areas, and as more legislators come from urban backgrounds, laws further regulating farms may eventually have a chance of passing there.

It's better to pass a law now to block such measures, he said. "As the saying goes, it's too late to shut the barn door once the horse is out."