Your 40s are a prime time to save for retirement, because not only are you in the midst of your peak earning years, but you have a couple decades left before you retire. This gives you the perfect opportunity to ensure you're on the right track for investing your savings, and to make any necessary adjustments.

While you might feel that you still have plenty of time left before retirement, it's important to start preparing as early as possible. If you wait until your 50s or later, it will be tough to catch up and hit your goals. By the time you reach your 40s, there are a few milestones you should achieve to ensure you're on track to retire:

Jar of retirement savings next to a clock

Image source: Getty Images

1. Know your retirement number, and have a plan for reaching it

Your retirement number is simply the target amount you want to save for retirement. You need to know how large of a nest egg you need to accumulate by the time you stop working full time, so that your portfolio will support you in retirement. While that may seem like a basic concept, 81% of Americans don't know how much money they'll need to save for retirement, according to a Bank of America Merrill Lynch survey.

If you don't have a goal in mind, it's tough to build a plan to get you there -- which leaves you at risk of reaching retirement age, only to realize you don't have enough socked away.

The easiest way to get a ballpark estimate of how much you'll need is to use retirement calculators. Online calculators use different algorithms and none will be 100% accurate for your individual situation, so it's a good idea to plug your information into several different retirement calculators to get a range of numbers.

Once you have a reasonably narrow target range in mind, you'll need to create an investing plan designed to reach that goal. The earlier you do that, the easier it will be to succeed.

For example, say you're 40, you have $50,000 in your retirement accounts, you plan to retire at 67, and you want to have a $700,000 portfolio by then. To reach your goal, you'll need to set aside around $450 per month (assuming you're earning a 7% annual rate of return on your investments). But if you were to wait until age 50 to start (all other factors remaining the same), you'd need to route roughly $1,500 per month into your investments to hit that target.

Ideally, it would be better to figure out your retirement number and start investing well before your 40th birthday. But in your 40s, you still have enough time to catch up -- if you hustle.

2. Pay down debt as fast as possible

You may not be debt-free by your 40s (especially if you're a homeowner), but it's smart to pay down as much debt as possible -- particularly high-interest debt. Carrying a balance on your credit cards, or using even more toxic types of debt like payday loans, can significantly limit your ability to save because you owe so much in interest.

When some people allocate their funds, they may choose to put more money into their retirement accounts, rather prioritizing paying off their debts. On the surface, that may seem like a wise move. But if you're paying more annually in debt interest than you earn on your investments, you're not doing your future wallet any favors. 

But you don't want to put your retirement savings plan totally on hold until you're debt-free -- because the longer you wait to save, the harder it is to catch up. Instead, find a balance between debt and saving. You don't need to pay off all your debt immediately, but make it a priority to pay off the types of debt with the highest interest rates. Once those are paid off, you'll have more money to invest for retirement, as well as for paying down less costly forms of debt like a mortgage.

Determining how much of your disposable income you should put toward debt versus retirement is not an exact science; the right answer for you will depend on several factors, such as your age, how much you already have saved for retirement, and the amount of high-interest debt you carry.

If you're 40 years old with a healthy retirement fund but a lot of debt, you might be best served to ease up on contributing to your 401(k) so you can put more money toward paying down your credit card balances. On the other hand, if you're nearing your 50s with next to nothing saved for retirement, but your debts are mostly low-interest -- a mortgage and a favorable car loan -- focus more on retirement while you still have time for compound growth to work its magic on your stock portfolio.

3. Don't play it too safe with your investments

Sometimes investing may seem counterintuitive. You want to protect your retirement funds as best you can, which may tempt you to seek out "safer" investments such as CDs or money market funds. While there's nothing inherently wrong with them, they have much lower rates of return than higher-risk investments like stocks.

Of course, when you invest in stocks, there's no guarantee that you'll earn a high return every single year. Instead, there will be good years and bad years, but over time, patient long-term investors should see a clear upward trend. Keep in mind, too, that investing in stocks doesn't necessarily mean choosing individual companies to invest in. You can invest in index funds, mutual funds or exchange-traded funds (ETFs) that spread your money across dozens or hundreds of different stocks -- a strategy that lowers your risk through diversification, but still generates significantly higher returns than you'd achieve with more stable asset classes than stocks.

For example, money market funds typically provide annual returns of just 2% to 3%, while index funds deliver average annual returns of 7% to 8% per year.

That may not seem like a big difference, but consider this example: You invest $300 every month for 25 years in a stock index fund that earns a 7% annualized return, while your twin did the same with a money market fund earning 2% a year. At the end of that period, your twin would have about $115,000 socked away. You -- with your "riskier" strategy -- would have about $228,000 -- nearly twice as much.

It's also important to consider inflation. If your investments only earn 2% to 3% per year, you may actually be losing real purchasing power, because the inflation rate is higher than your rate of return.

Your 40s are a great time to give your finances a checkup. If you're off track, you still have time to make adjustments -- but don't wait too long. The sooner you establish a retirement plan and kick your investment strategy into high gear, the healthier your nest egg will be when you need it down the road.