Many Americans started investing for the first time during the pandemic, but even though their trades may have been free, the money involved might soon come with a bill from the IRS. Here are four things that could trigger a tax-related hit — and what you can do to soften the blow.

1. You sold shares at a profit

What might happen: You might have to give the IRS a piece of the profits from your stock sales. What capital-gains tax rate you pay can depend on how much you made, what other income you have, your tax-filing status and how long you owned the investment.

"You could pay a pretty hefty penny depending on what your tax bracket is," said Naomi Ganoe, a certified public accountant in Akron, Ohio.

How to cope: One strategy is tax-loss harvesting, which involves selling poor-performing investments at a loss and using those losses to offset your profits. Another option: Hold shares for at least a year to qualify for more-favorable long-term capital-gains tax rates.

"You never want to do everything just for the taxes," Ganoe says. "You want to look at the whole situation."

2. You received dividends

What might happen: The IRS may want a cut of your dividends — even if you automatically reinvested those dividends and didn't receive any in cash.

"That's one of the surprises," Ganoe says. "No money came back to them, but now they've got to pay tax on it."

What tax rate you pay depends on the nature of the dividend. IRS Publication 550 has the details.

How to cope: Consider doing your trading inside a retirement account such as an IRA, said Gary DuBoff, a certified financial planner in New York. That way you may be able to defer, or in some cases avoid, a dividend tax bill until you make withdrawals in retirement.

3. You had over $200,000 of income

What might happen: You may owe a 3.8% net investment income tax if your modified adjusted gross income is over $200,000 for single filers or $250,000 for married couples filing jointly.

"On your investment income, that would be interest, dividends and capital gains," DuBoff says.

How to cope: Make sure you take every tax break you qualify for this year.

"Your itemized deductions or your standard deduction — that could offset your interest, dividends and capital gains," DuBoff said. "There's no one size fits all."

4. You want to do your own taxes

What might happen: Investment-related tax forms could mean spending more time on tax prep this year, or higher bills for a tax pro to do the work.

For example, you may need to file a Schedule B form to report interest and dividends you received, and a Schedule D could be in your future if you had capital gains, Ganoe said. You also may need to fill out extra forms for the alternative minimum tax.

How to cope: If you are hiring someone, keep your paperwork in order and get on your tax preparer's calendar early. Many preparers charge extra for disorganized records or rush jobs. If you're planning on doing your own taxes, you may need to upgrade to a more sophisticated (and likely more expensive) package that can handle investment-related tax situations. But don't wait until the last minute to choose software — prices tend to go up about a month before the tax-filing deadline.