Telling your spouse you want to divorce them is not the sort of thing you should use as an idle threat. You should only say it if you are sure you mean it.
It is not something to say in the heat of an argument, either. Save it for a calmer moment. That way, you can plan what you say and hopefully get a more reasonable reaction from your spouse.
Here are some tips for choosing the ideal moment, or at least one that is good enough:
Is it safe to do so?
If your spouse gets violent, a safe moment might be when you and your children have already moved far out of their reach.
If violence is not an issue, then safety is more about ensuring the discussion does not distract either of you. Don’t do it in the car or when about to rappel down a cliff face.
What do you have planned for the next few days?
If tomorrow is your child’s birthday, maybe save telling your spouse till afterward to avoid ruining things. The same applies if your spouse is about to sit an important exam. It would be unfair to burden them with the news just before.
Do you have plans in place?
Maybe ask a friend if you can stay for a few days to give your spouse space. Ensure you have enough money to cover immediate costs if your spouse tries to limit your access to funds.
Getting legal help to understand more about how divorce works will help you prepare for what happens next.