The attorney general is to publish guidance on Twitter to help prevent social media users from committing contempt of court when commenting on legal cases.
Dominic Grieve QC said it was designed to make sure fair trials took place.
Peaches Geldof recently apologised for tweets relating to a case, and several people were fined last year for naming a woman raped by footballer Ched Evans.
The advice will apply to court cases in England and Wales.
The rise of social media has meant that conversations about criminal cases, once had down the pub or over the garden fence, are now instantly published online - and can be shared with thousands, BBC legal correspondent Clive Coleman says.
But Facebook and Twitter are publications subject to the same laws that in practice used to apply only to the mainstream media.
Anyone commenting about a case or defendant in a way that could prejudice a trial could be prosecuted for contempt and imprisoned.
That is why the attorney general is going to start publishing advice - that previously only went to the media - to the public via his website and Twitter feed.
It is designed to help inform people about the legal pitfalls of commenting in a way that could be seen as prejudicial to a court case or those involved.
Mr Grieve said blogs and social media sites allow individuals to reach thousands of people with a single post, which he said was an "exciting prospect" but one which "can pose certain challenges to the criminal justice system".
He said he was not proposing "some sort of big brother watch" but wanted to educate people, possibly starting in schools.
Guidelines currently issued to the media about high-profile cases could be published online and through Twitter to prevent legal risks and the collapse of trials, he said.
Mr Grieve said tweets by a juror had caused one sexual offences case to collapse, costing £300,000 and "requiring all the witnesses to go through the process all over again".
And he said misuse of social media could undermine the fairness of trials, which could call into question "the whole future of jury trials, which most people regard as a very important safeguard for our freedoms".
He said the "simplest rule" people should follow is not to comment on live trials online.
Technology expert Tom Cheesewright said social media offered "instant publishing".
He said some individuals have more Twitter followers than national newspapers have subscribers but - unlike journalists - they do not have legal training or "an editor to stop them".
People may write posts while drunk or in "emotional states", he added.
"It's very unlikely we're going to have rules that stop this happening," he said.
"It's going to be about education and part of that education is going to come from high-profile prosecutions."
He said laws for print media had developed over many years and society would have to "go through the same process with social media" to develop laws and "public understanding".
Rupinder Bains, a lawyer specialising in social media, said she did not think many people would read the attorney general's tweets and guidelines.
But she said if more people were prosecuted the publicity would lead to "future prevention".
Asked about people who tweet in the belief that they will not be prosecuted for breaching legal rules, she said: "You will be eventually. The law will catch up."
Peaches Geldof apologised last week for tweeting the names of the two mothers whose babies were abused by rock star Ian Watkins.
Police are investigating the tweets over concerns that they identified protected parties.
The HM Courts and Tribunals Service has told BBC Newsbeat it is sorry for publishing the names of the other defendants in the Watkins case online.
The courts service admitted it had "mistakenly" published the names of two mothers convicted of sexually abusing their children and said the names were "quickly removed".
The case of Ched Evans, who was jailed for rape, generated more than 6,000 tweets, with some people naming his victim.
Complainants in sexual offence cases get lifelong anonymity from the moment an allegation is made.