Exodus 21:4

4 If his master gives him a wife and she bears him sons or daughters, the woman and her children shall belong to her master, and only the man shall go free.

Exodus 21:4 in Other Translations

KJV
4 If his master have given him a wife, and she have born him sons or daughters; the wife and her children shall be her master's, and he shall go out by himself.
ESV
4 If his master gives him a wife and she bears him sons or daughters, the wife and her children shall be her master's, and he shall go out alone.
NLT
4 “If his master gave him a wife while he was a slave and they had sons or daughters, then only the man will be free in the seventh year, but his wife and children will still belong to his master.
MSG
4 If the master gives him a wife and she gave him sons and daughters, the wife and children stay with the master and he leaves by himself.
CSB
4 If his master gives him a wife and she bears him sons or daughters, the wife and her children belong to her master, and the man must leave alone.

Exodus 21:4 Meaning and Commentary

Exodus 21:4

If his master have given him a wife
One of his slaves, a Canaanitish woman, on purpose to beget slaves on her, since all born in his house were his own; this is supposed to be after he was come into his house, and into his service:

and she have born him sons or daughters;
as she might have born him several of the one sort, or the other, if she was given to him quickly after his servitude began:

the wife and her children shall be her master's:
she being his slave, and bought with his money, he had a right unto her, and to the children belonging to her, the birth following the belly; and being born in his house, they were also his. Jarchi here observes, that the Scripture speaks of a Canaanitish woman, for an Hebrew woman went out at the sixth year, and even before the sixth, if she produced the signs, that is, of puberty:

and he shall go out by himself;
without his wife and children: if it be objected to this law, that it is contrary to the law of marriage, which is indissoluble, but by this dissolved; it may be replied, that the servant was not obliged by it to leave his wife, unless he chose it; on complying with certain conditions after mentioned, he might continue with her; besides, she was, according to Jarchi, but his secondary wife, and not only so, the marriage was not lawful, being with a Canaanitish woman, and not agreeable to the Lord; and being also her master's slave, to whom he had a right, he could retain her if he pleased, having only given her to his servant to beget slaves on for him.

Exodus 21:4 In-Context

2 “If you buy a Hebrew servant, he is to serve you for six years. But in the seventh year, he shall go free, without paying anything.
3 If he comes alone, he is to go free alone; but if he has a wife when he comes, she is to go with him.
4 If his master gives him a wife and she bears him sons or daughters, the woman and her children shall belong to her master, and only the man shall go free.
5 “But if the servant declares, ‘I love my master and my wife and children and do not want to go free,’
6 then his master must take him before the judges. He shall take him to the door or the doorpost and pierce his ear with an awl. Then he will be his servant for life.
Scripture quoted by permission.  Quotations designated (NIV) are from THE HOLY BIBLE: NEW INTERNATIONAL VERSION®.  NIV®.  Copyright © 1973, 1978, 1984, 2011 by Biblica.  All rights reserved worldwide.