With inflation rates approaching their highest point in a decade and select sectors of the market losing value right now, investors may be worried about the stock market and looking for safer places to put their money.

But rising inflation doesn't mean you need to pull your money out of the market. There are investment options like dividend stocks that provide a potential option for your money as their regular payouts can help your portfolio account for inflation. There are other stocks that do well no matter the broader economic situation, such as companies that provide discounted essentials.

Kimberly-Clark (KMB 1.28%) and Costco Wholesale (COST 0.17%) are good examples of companies that do both and do them well. Let's see why these two companies can help your portfolio beat inflation. 

A baby in a diaper with his head upside down.

Image source: Getty Images.

1. Kimberly-Clark: Products that never go out of style

Kimberly-Clark is a leader in the production and sale of household basics such as toilet paper and diapers. It's not a growth stock, but it is a safe stock. Consumers will always need its products, something that was most recently demonstrated during the pandemic.

The company, which owns brands such as Kleenex and Huggies, had its highest sales growth in years in 2020, with a 4% increase in net sales, and a 6% increase in organic sales, which are sales from existing businesses.

That outlier performance is starting to taper off, with a 5% sales decrease in the first quarter of 2021. Kimberly-Clark s not quite lapping pandemic performance yet, but perhaps customers already stocked up on enough essentials. The company had to downgrade its full-year guidance to 0% to 1% revenue growth instead of 1% to 2%, but that level of performance would still be impressive considering its performance over the past year.

The downgraded forecast won't affect the dividend. As an industry leader in essential products, with five brands that bring in at least $1 billion annually, Kimberly-Clark is typically flush with cash, and it traditionally pays a portion of that cash out in the form of dividends. 

Kimberly-Clark is a Dividend Aristocrat, and it has raised its dividend annually for the past 49 years. Between the company's commitment to the dividend, products that people always need to buy, and continued strong cash position, Kimberly-Clark's dividend is as safe as any. It also boasts a 3.43% yield at the current price, more than double the 1.4% S&P 500 average, and it's a great choice if you're worried about inflation.

2. Costco: Getting the most use out of your membership

Costco has built a warehouse store empire selling bulk products at discounted prices. Customers pay $60 for a basic yearly membership or $120 for an executive membership to take advantage of these prices, and that has fueled high sales growth for most of the company's history. If a consumer is looking to squeeze the most out of their budget, chances are that they have considered shopping at Costco.

Customers choosing produce in a supermarket.

Image source: Getty Images.

Even more, Costco sees its low margins as a competitive moat and tries not to raise prices. Some of Costco's products have remained at the same price for more than a decade, such as the famous $4.99 rotisserie chicken, while others fluctuate according to market dynamics. On the second-quarter conference call, CFO Richard Galanti said: "We always want to be the last to raise and the first to lower."

Costco's margins are typically very low double-digit percentages, around 11% to 12%, which is lower than the industry average of mid-20%. As prices rise, Costco will do what it can to keep its prices low and sales high.

Costco stock has rewarded customers over the years, beating the S&P 500, with a 16.6% annualized 10-year return versus the S&P 500's 12.1%. It pays a dividend that it raises annually and yields 0.75% at the current price. It also pays out special one-time dividends every few years that add to its value. Costco stock is a great choice in any market, and a smart pick if you're worried about inflation.