Prosecutors have set out new guidelines on whether messages posted on social media should be treated as a crime.
Lord Advocate Frank Mulholland said the test was simple: "If it would be illegal to say it on the street, it is illegal to say it online."
The Crown Office said it would not pursue satirical or mildly offensive humour or provocative statements.
But it promised a "robust" response to hate crime, stalking or credible threats of violence
The Crown Office and Procurator Fiscal Service has previously sought clarity on where the legal boundary lies in such matters.
The guidelines state that communications should be considered for prosecution if they:
- specifically target an individual or group which are considered to be hate crime, domestic abuse, or stalking
- constitute credible threats of violence to the person, damage to property or to incite public disorder
- may amount to a breach of a court order or contravene legislation making it a criminal offence to release or publish information relating to proceedings
- do not fall into the above categories but are nonetheless considered to be grossly offensive, indecent or obscene or involve the communication of false information about an individual or group which results in adverse consequences
The lord advocate said the aim was not to deny freedom of speech but the law would target internet trolls posting sectarian, homophobic or violent messages or pictures
"Those who use the internet to peddle hate or abuse, to harass, to blackmail, or any other number of crimes, need to know that they cannot evade justice simply by hiding behind their computers or mobile phones," he said.
"I hope this serves as a wake up call to them.
"As prosecutors we will continue to do all in our power to bring those who commit these crimes to justice, and I would encourage anyone who thinks they have been victim of such a crime to report it to the police."