Prohibiting the banning of politicians from social media sites may violate a host of federal laws, the judge says.

A federal judge on Wednesday issued an order blocking a Florida law from going into effect that would have allowed the state to punish social media companies for banning politicians or political candidates from their platforms. US District Judge Robert Hinkle’s preliminary injunction came a day before the law was to go into effect on Thursday.

Hinkle found that the law’s prohibition on “deplatforming” may violate companies’ free speech rights and that the legislation on the whole is “viewpoint-based.”

“The legislation compels providers to host speech that violates their standards — speech they otherwise would not host — and forbids providers from speaking as they otherwise would,” Hinkle wrote in his judgment.

Hinkle criticized the law as being too broadly written and found that promoting one viewpoint while restricting another isn’t a legitimate state interest.

“Like prior First Amendment restrictions, this is an instance of burning the house to roast a pig,” he wrote.

Signed into law last week by Republican Gov. Ron DeSantis, the bill would punish social media companies such as Facebook and Twitter for banning politicians and candidates for conduct they found to violate their terms of service. Sites that permanently ban or suspend politicians or candidates for more than 14 days could be fined as much as $250,000 per day under the law.

The bill was proposed after the high-profile banning earlier this year of President Donald Trump from Twitter and Facebook. Many conservatives argue the companies censor content for ideological reasons — a claim the social media firms have repeatedly denied.

Twitter permanently banned Trump on Jan. 8 “due to the risk of further incitement of violence” after the deadly riot on Capitol Hill. Facebook blocked Trump “indefinitely” the same day.

The bans followed a number of instances in which Twitter had obscured controversial Trump tweets with a warning label that included a link to more information and that let users click through to read the tweet.

The Florida legislation aims to “rein in social-media providers deemed too large and too liberal,” Hinkle wrote. “Balancing the exchange of ideas among private speakers is not a legitimate governmental interest.”

In addition, parts of the legislation are “expressly preempted” by federal law, he added.

NetChoice, an internet industry group that sued the state, praised the injunction for ensuring that social media remains “family friendly.”

“This order protects private businesses against the State’s demand that social media carry user posts that are against their community standards,” NetChoice President Steve DelBianco said in a statement. “Even better, it lets social media provide high-quality services to their users while keeping them safe from the worst content posted by irresponsible users.” 

Gov. DeSantis’ office said late Wednesday it would immediately appeal Hinkle’s ruling to the 11th Circuit Court of Appeals.

“We are disappointed by Judge Hinkle’s ruling and disagree with his determination that the US Constitution protects Big Tech’s censorship of certain individuals and content over others,” DeSantis Press Secretary Christina Pushaw said in a statement. “Gov. DeSantis continues to fight for freedom of speech and against Big Tech’s discriminatory censorship.”

The bill was designed to provide “real Floridians” with “protection against the Silicon Valley elites,” DeSantis said when he signed it last month. “If Big Tech censors enforce rules inconsistently, to discriminate in favor of the dominant Silicon Valley ideology, they will now be held accountable.”