Investing in the stock market is one of the most effective ways to generate wealth over time, but it can quickly become expensive.

A well-diversified portfolio should contain at least 25 different stocks, and when some stocks cost hundreds or even thousands of dollars per share, you could easily spend several thousand dollars just getting started.

Fortunately, there's a more affordable way to invest. With this strategy, you can buy pricey stocks like Amazon (AMZN -2.55%) for as little as $1.

Person sitting at a desk using a laptop with a child nearby.

Image source: Getty Images.

Investing on a budget

Currently, Amazon is priced at just over $3,200 per share. If you're new to investing or simply don't have that much cash to spend on a single stock, that price can be a dealbreaker. However, with fractional shares, you can invest in high-quality stocks for just a dollar or two.

With fractional shares, you're investing in a small slice of a share of stock rather than a full share. So, for example, rather than buying one full share of Amazon stock for $3,200, you could buy one-tenth of a share for one-tenth of the price, or $320.

Fractional shares can make it easier to invest on a budget. If you only have $5 to invest, you can invest in a tiny sliver of stock for $5. Or if you do have a substantial amount of money to invest but don't want to spend it all on a single stock, you can divide it up between multiple stocks through fractional shares.

Why fractional shares can be a smart strategy

Besides being a more affordable way to invest, there are other benefits to buying fractional shares. For one, it's easier to build a diversified portfolio. Rather than spending thousands of dollars buying dozens of full shares of stock, you can invest in 30 different stocks for as little as $30.

Of course, the smaller stake you own in a company, the smaller your earnings will be. But once you've built a core portfolio of stocks through fractional shares, you can start investing more in each stock a little bit at a time.

In addition, fractional shares could make investing less intimidating. If you like the idea of investing but aren't sure about sinking thousands of dollars at a time into the stock market, fractional shares can help you ease into it gradually.

A few things to consider before you get started

While fractional shares can be a fantastic way to invest affordably, there are a couple of factors to consider before you dive in.

It's still important to do your research before you buy, even if you're not investing a lot of money. It can be tempting to buy risky stocks simply because they're more affordable with fractional shares, but a bad investment is still a bad investment regardless of how much you paid for it.

Also, it's wise to maintain a long-term outlook with fractional shares. When you're not investing as much money, you won't see monumental returns right away. While that can be discouraging, remember that it takes time for your investments to grow. By continuing to invest consistently, you can see substantial gains over time.

Whether you're on a tight budget or simply don't want to spend a lot of money in the stock market, fractional shares can be a fantastic option to invest in even the most expensive stocks -- like Amazon. By getting started now and investing whatever you can afford, you'll be on your way to building wealth in the stock market.