It's impossible to predict with certainty whether a recession is coming, but certain developments sure make it more likely. President Donald Trump's tariff policies could lead to increased prices and plunge the economy into a downturn. The recent government shutdown, especially if it drags on, could lead us directly into a recession.

Of course, that may not happen, but it's not a bad idea for investors to prepare for that possibility by investing in stocks that are well-equipped to perform well during recessions. Here are two great examples: Walmart (WMT -0.14%) and Johnson & Johnson (JNJ 0.05%).

Two people shopping inside a retail store.

Image source: Getty Images.

1. Walmart

Some might point out that Walmart, one of the leading retailers in the U.S., is facing challenges. Trump's tariffs are increasing the company's expenses and forcing it to pass these costs on to customers, which in turn affects purchasing decisions. How will Walmart handle a full-blown recession when the purse strings get even tighter? In my view, the company will be just fine. Walmart has performed well for decades, generating steady revenue and profits even if the economy is not doing well.

The past is no guarantee of future performance, but Walmart's core business remains well-equipped to handle significant challenges. The company's retail footprint in the U.S. is one of the strongest. Roughly 90% of Americans live within 10 miles of one of the company's stores. So, for most U.S. consumers, Walmart is a convenient option.

Even if people become more price-sensitive during recessions, Walmart remains a great option. The company's size grants it significant negotiating power when purchasing items from suppliers. This allows it to pass these cost savings to customers. Even in an inflationary environment due to tariffs, Walmart should remain one of the lower-cost options compared to its peers, who would be dealing with the same challenge. 

Furthermore, the company has become even more convenient by doubling down on its e-commerce efforts. Walmart has one of the largest e-commerce footprints in the U.S., ranking second only to Amazon.

It's not just its size: Walmart is the second cheapest (again, behind Amazon) online retailer in the U.S. So, whether online or in its stores, Walmart should continue to offer competitive prices, making it a top option for shoppers looking to spend as little as possible.

Lastly, Walmart is an excellent dividend stock. The company is part of the elite group of Dividend Kings that have raised their payouts for at least 50 consecutive years -- Walmart's streak is at 53.

Opting to reinvest the dividend helps smooth out market losses. That's another reason why Walmart is an incredible investment option when preparing for a recession.

2. Johnson & Johnson

Johnson & Johnson is a leading healthcare giant. It offers products and services, such as pharmaceutical drugs, for which demand is not heavily dependent on the state of the economy. Johnson & Johnson has a diversified pharmaceutical portfolio across several therapeutic areas, including some of the biggest, such as oncology and immunology. Despite losing patent protection for one of its biggest growth drivers, Stelara -- an immunosuppressant -- in the U.S. this year (and in Europe last year), the company has continued to post strong financial results.

In the second quarter, the company's revenue increased by 5.8% year over year to $23.7 billion. Johnson & Johnson's adjusted earnings per share declined by 1.8% year over year to $2.77, due to several factors, including the effect of acquisitions. Nevertheless, this is nothing to be worried about.

Overall, Johnson & Johnson is performing well, and it should continue to do so. The company's navigation of the Stelara patent cliff shows its ability to overcome these meaningful challenges for drugmakers. Johnson & Johnson's medtech business enhances its operations with greater diversity. With the company working on the promising Ottava robotic-assisted surgery (RAS) system, it could capitalize on this massive growth opportunity over the long run as the RAS market remains underpenetrated.

Furthermore, with recent developments in the pharmaceutical industry, tariffs may not be as significant a problem for Johnson & Johnson. The company will face some headwinds, including legal challenges, but its robust balance sheet enables it to effectively navigate those obstacles.

Finally, Johnson & Johnson is also a Dividend King, having achieved 62 consecutive years of dividend increases. The company is an excellent choice to get you through a recession.