Genesis 38:9

9 But Onan knew that the child would not be his; so whenever he slept with his brother’s wife, he spilled his semen on the ground to keep from providing offspring for his brother.

Genesis 38:9 in Other Translations

KJV
9 And Onan knew that the seed should not be his; and it came to pass, when he went in unto his brother's wife, that he spilled it on the ground, lest that he should give seed to his brother.
ESV
9 But Onan knew that the offspring would not be his. So whenever he went in to his brother's wife he would waste the semen on the ground, so as not to give offspring to his brother.
NLT
9 But Onan was not willing to have a child who would not be his own heir. So whenever he had intercourse with his brother’s wife, he spilled the semen on the ground. This prevented her from having a child who would belong to his brother.
MSG
9 But Onan knew that the child wouldn't be his, so whenever he slept with his brother's widow he spilled his semen on the ground so he wouldn't produce a child for his brother.
CSB
9 But Onan knew that the offspring would not be his; so whenever he slept with his brother's wife, he released his semen on the ground so that he would not produce offspring for his brother.

Genesis 38:9 In-Context

7 But Er, Judah’s firstborn, was wicked in the LORD’s sight; so the LORD put him to death.
8 Then Judah said to Onan, “Sleep with your brother’s wife and fulfill your duty to her as a brother-in-law to raise up offspring for your brother.”
9 But Onan knew that the child would not be his; so whenever he slept with his brother’s wife, he spilled his semen on the ground to keep from providing offspring for his brother.
10 What he did was wicked in the LORD’s sight; so the LORD put him to death also.
11 Judah then said to his daughter-in-law Tamar, “Live as a widow in your father’s household until my son Shelah grows up.” For he thought, “He may die too, just like his brothers.” So Tamar went to live in her father’s household.
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.