Commodities have emerged as an investment alternative over the last decade. In Dec. 2020, even water futures started trading on stock exchanges. There are various classes of commodities available to traders. Are commodities a safe investment, and should you invest in them?Globally, there's more trading in commodity markets than in stocks, and there are many participants in commodity markets. There are buyers and sellers trying to hedge their positions, and traders and arbitragers trying to benefit from price movements in commodities.Types of commodities you can tradeCommodities aren't homogenous, with some being safer investments than others. Some commodities can be riskier than stock markets. Basically, commodities can be divided into three types: \n\n- Energy.\n- Metals.\n- Agriculture. \n\nWe can further divide these types into different classes. For instance, metals can be divided into industrial metals and precious metals, and agricultural commodities can be divided into crops and livestock.Are commodities a safe investment?Commodity prices are a function of demand and supply. For example, crude oil prices have been weak since 2014 when OPEC decided against cutting production despite it soaring in the U.S. In 2020, oil prices crashed as supply-side issues were compounded by economic turmoil. Due to COVID-19 lockdowns, the demand for gasoline and crude oil tumbled. In April 2020, WTI contracts even turned negative for a brief time.In contrast, stocks can never go negative—at their worst, they can fall to zero if the company goes bankrupt. Therefore, some commodities can be riskier than stocks, but some commodities are safer than others.Gold as a safe-haven assetWithin the commodity market, we also have precious metals. These include gold, silver, and platinum-group metals, which are platinum, rhodium, palladium, osmium, iridium, and ruthenium.Gold, the safest investment among precious metals, is considered a safe-haven asset because it tends to do well in economic crises. The metal was among the best investments in 2020 due to the COVID-19 pandemic. And even after news came out of COVID-19 vaccine candidates, gold stayed one of the year's strongest asset classes.Can commodities diversify my portfolio?While commodities might not be the safest of investments, they can certainly diversify your portfolio and hedge against inflation. In high inflation, stocks tend to fall, whereas commodities tend to do well. For example, in the 2008 financial crisis, crude oil prices surged.How to invest in commoditiesTo invest in commodities, you can: \n\n- Invest in the commodity directly. However, you'd need to store the commodity, which can be cumbersome.\n- Invest through futures. Most commodity trading happens in the futures market. You can also use leverage when trading in commodity futures.\n- Invest in ETFs. Some ETFs invest in commodities such as gold, silver, and copper.\n- Invest in stocks. You may also invest in stocks of companies that produce commodities. Stocks of commodity producers are a leveraged bet on the underlying commodity.You could also invest in mutual funds that invest in commodities or commodity producers. Whether you choose an active and passive fund should depend on your investment needs.