Social Security beneficiaries may find an unwelcome surprise when they file their taxes.

One of the most effective ways to maximize your Social Security benefits in retirement is to keep your tax burden low. Doing so requires some careful financial planning and making the most of your various retirement savings accounts. But if you plan things out, you can significantly reduce the taxes on your Social Security benefits, and keep more for yourself.

Here are three ways to save on taxes while collecting Social Security.

An adding machine sitting on top of tax forms.

Image source: Getty Images.

1. Move to a state that doesn't tax Social Security

There are 38 states that don't tax Social Security retirement benefits, along with the District of Columbia.

If, however, you live in one of the other 12 states, you may have to pay taxes on at least a portion of your Social Security. It's possible to avoid taxes on Social Security entirely in some of those states, but it's nearly impossible in many others if you have even a modest Social Security check.

Of course, moving to another state just for tax benefits isn't in the interest of most retirees. Without work tying you to a location, you probably chose your home for other reasons besides money: Your friends live there, the weather is nice, or the cost of living fits your budget.

Luckily, there are ways to reduce your Social Security tax bill without moving.

2. Limit withdrawals from traditional IRAs

Every single dollar you withdraw from your tax-deferred retirement accounts counts toward your adjusted gross income, the main determinant of your tax bill.

The way taxes work on Social Security income is by combining your adjusted gross income, any nontaxable interest, and half of your Social Security income. If that number is below a certain threshold, $25,000 for individuals and $32,000 for couples, you won't pay any taxes on your Social Security benefits.

The amount above that level and below $34,000 for individuals or $44,000 for couples, you'll add 50% of your Social Security benefits to your taxable income. And any amount above that, you'll add 85% of your benefits to your taxable income.

Effectively, every dollar you withdraw from your retirement account that pushes you further above those thresholds will get taxed at 1.5x or 1.85x the rate until your entire AGI surpasses the top of the thresholds. As such, it's valuable to limit your distributions as much as you can as you bump up against those thresholds. That's why minimizing your required minimum distributions is an effective tax planning strategy.

The best way to get around this is through the use of Roth accounts. Withdrawals from Roth accounts don't count toward your AGI. If you can make strategic Roth conversions before you collect Social Security, you'll likely be able to lower your lifetime tax liability.

Another possibility is to use qualified charitable distributions (QCDs) from your IRA. QCDs come straight out of your IRA to a nonprofit, so they don't count toward your AGI. That's much more effective than the charitable contribution itemized deduction.

3. Strategically sell assets in your brokerage account

When you sell a security in your brokerage account, you'll only pay taxes on the gains.

If you can limit your gains to the point where you stay below the combined income threshold for Social Security taxation, you'll find yourself with a very small tax bill. Not only will you pay 0% on your Social Security income, you'll likely pay 0% in taxes on your capital gains as well.

There are a couple of strategies you can use in combination to keep your tax bill manageable. First, sell specific tax lots. A tax lot is a group of shares bought in a single purchase for the same price. Using specific tax lots allows you to closely control your capital gains. If you have tax lots you bought at a high price, you can liquidate them with limited tax implications.

Of course, a lot of your assets will likely have substantial unrealized gains. In that case, it's best to sell those lots in conjunction with lots that you've lost money on. The losses will offset the gains. Or, if you need to withdraw funds from your retirement account, you can offset up to $3,000 in regular income with capital losses from your taxable investments.

Better planning produces a better result

If you make a plan to keep your taxes low, you'll likely do better than simply drawing from your accounts as you need and passively accepting your tax bill come April. Even if you aren't able to completely eliminate taxes on your Social Security income, these strategies should help you lower the impact of taxes on your budget.