She doesn't sound like a very reasonable person. She's certainly not willing to respect any boundaries, and if she really did pull a knife on you, then she's dangerous as well.
Trying to talk to her and explain yourself is a lost cause, and frankly, not worth your time. Her bad-mouthing you to your family, however, is a big deal, and one that must be addressed as soon as possible. I would sit down with your parents, and tell them what happened. I would also sit down with any siblings and good friends (separately) and do the same.
Describe that you were still living together after having broken up. That she invaded your privacy by reading private messages, and that she misunderstood the content of those messages. Based on that misunderstanding, she then proceeded to pull a knife on you, and is currently running a campaign of misinformation against you. She's toxic, and they need to understand that.
At no point should you try and explain what you were speaking to your friends about, or what the inside joke may have been. That's private, and you owe no one an explanation about it. At most, admit that it may have been a bit of an immature conversation, but that what matters here is that it was private.
I would ask them for their support in this matter, and I hope that they know you well enough to realize that her account of events is not to be trusted. They'll hopefully spread the word to any other relatives of yours who may have heard about the debacle, and stand up for you in any public setting where this topic comes up.
As far as what her family thinks, if you happened to be fairly close with her parents prior to this incident, I would possibly send them a letter explaining your point of view, underlining that you were never unfaithful, and that she pulled a knife on you over information she misinterpreted after essentially spying on you. This is probably pissing in the wind, as they say, because it's very likely that they will stand by their daughter's account come hell or high water, but you could do it if you feel you have to set the record straight.
Note: Anything you say can, and will be used against you. Don't say anything to her family (in writing or otherwise) that could be misinterpreted, and possibly used against you in the court of public opinion, or worse, in a legal battle. This may sound paranoid, but I've met people who've endured with pretty crazy stuff from similarly angry and vengeful exes.
I would then move on with my life, and be ever thankful of having (mostly) dodged a speeding bullet. Not to mention a knife.