See https://www.irs.gov/newsroom/questions-and-answers-on-the-net-investment-income-tax
Here is a calculator: https://www.irstaxapp.com/who-pays-net-investment-income-tax