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 by voters in November.

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 or battery cages for chickens, which critics say abusively restrict 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 past 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 amendments this year. Oklahoma voters rejected a similar amendment 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 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 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 of the American Society for the Prevention of Cruelty to Animals, say those 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 affects 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 ways 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 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 must convert over half its egg production to cage-free systems by 2025, up from the current rate of 10 percent.

Consumer expectations have shifted as animal welfare groups such as the Humane Society have used undercover investigations to expose industry practices. Videos and images 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.

Farmers say that keeping animals in cages is the safest and most sanitary way to care for them. And farming groups say the practices encouraged by animal welfare groups might not make life for farm animals any better.