This conversation is understandably difficult, but also very important. Always remember that you know your children better than anyone else, so you are the expert.
The conversation is dictated largely by the age of the child and the overall situation. For younger children, because they do not have as good of an understanding of time, less notice is needed. For instance, explaining to a pre-school age child that his father will move out in several weeks may be sufficient. On the other hand, an older child will need more time to adjust so it is important to provide the older child with a few months advanced notice.
Regardless of the age, it is very important that you are in a position where you can sit down and talk to your children in a calm manner. Children may have many important questions such as where are they going to live, where will the pets live, and why is the divorce happening. Before initiating the conversation, it is very important that you can comfortably and calmly answer these questions.
Ideally, it is also important for both parents to tell the children about the divorce. Although there is a temptation to reveal the legitimate gradiences that led to the divorce, if possible, it is important to convey the message to the children in a united front. However, if you fear your spouse or if there is a history of domestic violence, then the safety of yourself and your children must be prioritized above everything else. In such cases, conveying the message to the children as a united front is simply not possible.