The stock market is one of the greatest wealth-building tools that exists, as long as you follow a few key rules. You'll need to know what you're investing in, watch your fees, build a diversified portfolio, and invest for the long term if you want the best chance to build wealth in the market. 

You'll also need to do one of two other things: Invest early, or invest a lot. The good news is, you don't necessarily need to do both if your goal is to invest your way to a $1 million nest egg. 

Burlap bag full of $100 bills.

Image source: Getty Images.

The timeline to $1 million 

The stock market can make you a millionaire pretty quickly if you pick the right investments and put enough money into them.

Many people aren't great at picking stocks that beat the market, though, so investing in index funds that track the market's performance is often the right way to go. If you do that, you can expect to comfortably earn around a 7% to 8% average annual return over time. 

Assuming you earn that 8% return, the chart below shows how long it would take you to amass a $1 million nest egg depending on the amount of money you invest each month. 

If you invest this much per month: You'll be a millionaire in this many  years:
$100 52.92
$250 41.67
$500 33.42
$750 28.75
$1,000 25.58
$1,500 21.33
$2,000 18.42
$3,000 14.75
$5,000 10.67

Source: Author calculations. Assumes 8% average annual return.

As you can see, if you're making small investments, it will take a long time to hit $1 million. That may be OK if you're investing for retirement and you start in your 20s. But if you're in your 40s and want to become a millionaire soon, you're going to have to be much more aggressive in the amount you invest. 

Putting money into the market early on in your life allows plenty of time for compound interest to work its magic. Compound interest occurs when your investment returns are reinvested and earn returns of their own. It can lead to exponential growth and, when given enough time to work, can make it easy to amass a fortune even when investing small amounts.  

You can't go back in time and start investing $100 a month at age 20 if you're already middle age. But these numbers show that it's not out of reach for most people to become millionaires if they start in their 30s or even their 40s.

Saving $1,500 a month starting at age 45 would still allow you to achieve millionaire status by about the time you hit your full retirement age for Social Security. While $18,000 a year in investments would be a reach on an average salary, it could be doable if you're putting money into a 401(k) to take advantage of tax breaks and you get an employer match to help you hit your target.

Obviously, you can make amassing a $1 million nest egg a lot easier if you do start early, though. And since you can't go back in time, right now is the best time to begin investing if you haven't already.

Even if you start small and can't invest the requisite monthly amount to get to millionaire status, try to invest something to get your money working for you. Over time, hopefully the market can make you a millionaire.