In the United States, at least, diplomatic immunity can be used as essentially a complete defense against any crime, no matter how serious. As the link below says,
If diplomatic immunity is used as a shield, the police cannot prosecute, no matter how serious the crime may be.
This is true of full fledged diplomatic agents and of their immediate families. This is why, for example, the son of a diplomat was allowed to leave the country in 1983 even though he was suspected of multiple rapes.
If the country that the diplomat is from agrees, however, the diplomat can actually be turned over to the US court system. In that sense, diplomatic immunity is not a complete defense, but the diplomat's country does have to agree.
In addition, diplomatic immunity extends to civil cases. A diplomat may not be sued in the United States.