Investing in the stock market is one of the best ways to grow your net worth. Since 1971, the S&P 500 has generated average annual returns of 10.9%, allowing patient investors the opportunity to amass life-changing wealth due to the benefits of compound interest. 

But there are three specific companies that have absolutely trounced the overall market, producing long-term returns that would be the envy of Wall Street. Investing just $1,000 in these stocks at their respective initial public offerings (IPOs) resulted in massive gains exceeding $300,000 over time. 

Read on to learn about these well-known businesses. 

Person holding suitcase with bundles of hundred dollar bills.

Image source: Getty Images.

1. Costco Wholesale: $450,000 

A $1,000 investment in Costco Wholesale (COST 0.17%) in 1985 (when it went public) would be worth approximately $450,000 today. The warehouse club operator has experienced such an impressive rise in its stock price due to steady store openings, which led to ballooning sales and net income. 

Costco currently has 809 locations globally offering up anything from clothing and groceries to electronics and home furnishings. Stores are essentially one-stop shops for customers, who must pay an annual membership fee of $60 (Gold Star membership) to have the privilege of shopping there. But many feel it's well worth it, as Costco is known to have some of the lowest prices around. Further enhancing the experience are a generous return policy and a "treasure hunt atmosphere" encouraging frequent visits. 

Sales in the most recent fiscal year totaled $163 billion, making Costco one of the world's largest retailers. The company has thrived and will likely continue to thrive going forward because it relentlessly focuses on taking care of its customers by keeping prices as low as possible, making it difficult for rivals to compete. 

2. Home Depot: $15.7 million 

Home Depot (HD -1.77%) is the world's leading home-improvement retailer, and its stock, which started trading publicly in 1981, has turned a $1,000 investment into an eye-popping $15.7 million today. 

The Atlanta-based business has exploded to a $343 billion valuation due to expansion primarily here in the U.S. Many people love to spend money on improving their homes, and Home Depot, with its nearly 2,300 stores, is here to cater to those needs. 

During the pandemic, with consumers in possession of stimulus checks and limited on travel and leisure spending options, the business really shined. Revenue in each of the last four quarters soared more than 23%, with the most recent quarter registering a 31% gain in same-store sales. Additionally, Home Depot's ability to deliver a seamless omnichannel shopping experience resulted in an impressive 55% of online orders in first-quarter 2021 actually being fulfilled at a store. 

While it would be unreasonable to expect the same monster returns going forward, a hot housing market, still historically low interest rates, and millennials increasingly looking to buy homes should all provide good support for Home Depot's prospects in the years ahead. 

3. Starbucks: $345,000 

Starbucks (SBUX 1.00%), though probably the most recognized consumer brand on this list, is the worst performer, turning a $1,000 outlay in 1992 (when it IPO'd) into roughly $345,000 at current prices. The business today is truly global, as its 32,943 stores satisfied enough caffeine cravings that sales in the most recent quarter totaled $6.7 billion. 

The company has become a coffeehouse empire. Success in the U.S., which accounted for nearly two-thirds of revenue in the quarter, has gotten Starbucks to this point. But in the years ahead, it will likely be international growth, particularly in China, that will drive the business to new heights. In this fiscal year alone, Starbucks plans to open 600 net new locations in the world's most populated country. That's more than half of the 1,100 net new stores that will be opened globally. 

Even with a long history of success, management still has huge ambitions. During an investor day presentation given last December, CFO Patrick Grismer boldly claimed that by 2030, Starbucks plans to have 55,000 stores open. If this is achieved, it would make the business the largest restaurant chain in the world. 

What really matters 

These three companies have made many of their long-term shareholders extremely rich. The catch, however, is that you must be invested through the ups and downs, and for many years. There is no substitute for time in the market. 

Look at Costco, Home Depot, and Starbucks as great examples of the amount of wealth that can be built by being patient in the stock market.