Because index-fund fees are so low—zero in some cases—you might think it’s impossible to own the same stocks directly yet earn a better return.

But an increasing number of investors are doing just that, in their taxable accounts, by using a strategy known as direct indexing. The tactic involves buying the underlying securities of an index, such as the S&P 500, then selling the stocks that decline. In a good year, the investor captures the gains of the chosen index while creating losses that at tax time help offset capital...

Because index-fund fees are so low—zero in some cases—you might think it’s impossible to own the same stocks directly yet earn a better return.

But an increasing number of investors are doing just that, in their taxable accounts, by using a strategy known as direct indexing. The tactic involves buying the underlying securities of an index, such as the S&P 500, then selling the stocks that decline. In a good year, the investor captures the gains of the chosen index while creating losses that at tax time help offset capital gains, thus helping them keep more of their profits.

By contrast, if you own the S&P 500 through an index fund or exchange-traded fund, you benefit from gains if the index rises, of course, but you produce no harvestable tax losses unless the entire fund drops in value.

Direct indexing can be tailored to each investor’s needs. For example, an energy executive whose personal portfolio is heavily dependent on oil and gas could directly own all of the equities in the S&P 500 except fossil-fuel stocks.

But the biggest appeal is the increased ability to offset gains with tax losses. A person using direct indexing typically has gains and losses in any given year and, thus, opportunities to use tax losses to defer paying capital-gains taxes. Many wealthy investors use the strategy to completely avoid capital-gains taxes while building a portfolio of stocks to leave to heirs or charity some day.

Terry Burnham, a finance professor at Chapman University, co-wrote a paper that studied the effectiveness of tax-loss harvesting on a portfolio of the 500 largest U.S. common stocks by market capitalization from 1926 to 2018. It calculated that a person who continued to invest in the portfolio each month using a tactic akin to direct indexing would have improved after-tax returns by 1.08 percentage points annually compared with just owning the portfolio and not tax-loss harvesting. The calculation assumed a long-term capital-gains tax rate of 15% and a short-term rate of 35%.

“It will be transformative,” Dr. Burnham says of direct indexing. “Everybody who owns an S&P 500 [fund] in a taxable account should stop owning it.”

SHARE YOUR THOUGHTS

What do you think about direct indexing? Join the conversation below.

Until recently, direct indexing was performed by a few big firms for institutional clients and the ultrawealthy. Advisers would charge affluent clients fees of perhaps 0.3% of assets to create and maintain a portfolio of direct indexes. Today the software costs in direct indexing have fallen to the point where financial advisers and big investment firms are offering direct indexing for more retail clients. Robo adviser Wealthfront, which charges clients just 0.25% of assets to manage their money, uses direct indexing on certain accounts.

Vanguard Group recently agreed to buy a provider of direct-indexing technology and indicated that it would offer direct indexing to customers in its advisory business, though it offered few other details. It already has been offering direct indexing to certain clients through a pilot program.

“Technology-driven solutions such as direct indexing continue to reshape our industry, driving better investment outcomes and lowering costs for clients,” Vanguard Chairman and CEO Tim Buckley said in announcing the acquisition.

The software typically being used can analyze correlations between stocks, making it unnecessary to own every stock in an index. According to experts in the strategy, it’s only necessary to own 75 to 100 of the stocks in the S&P 500 to closely match its returns. Next, the software detects when a stock owned by a client in a direct index falls below its cost basis. The program flags such stocks to be sold. It then recommends shares of similar companies to purchase as replacements. Two reasons for this: to avoid running afoul of IRS wash-sale rules that forbid using the same or “substantially identical” stocks to replace a stock sold within 30 days and claiming a tax loss; and to keep the client’s direct-index return close to that of the S&P 500.

One criticism of direct indexing is that it can result in investors missing out on blockbuster gains of young stocks still too small to be included in a direct index.

“You’re far more likely to pick up a stock after all the juice has been squeezed out,” says William Bernstein, a financial author and money manager who has been an advocate of index funds. Mr. Bernstein says he doesn’t like the idea of trying to duplicate indexes by owning a smaller number of stocks.

You can own the S&P 500 through an index fund or ETF, but ‘direct investing’ is another way. The NYSE on Nov. 26.

Photo: Richard Drew/Associated Press

The strategy also works better with indexes of highly liquid stocks, like those in the S&P 500, compared with indexes of small-cap or foreign stocks, says

Larry Swedroe, chief research officer for Buckingham Strategic Wealth. That is because trading costs tend to be higher on less liquid stocks.

Dominic Corabi, co-founder of Wedmont Private Capital near Philadelphia, performs direct indexing for his clients using software from Omaha, Neb.-based Orion Advisor Technology LLC. The program helps him go through the indexes he has created for clients in search of losing positions to sell, and helps him identify replacement stocks. How often he generates sales depends on the market, he says. During the brutal market downturn around the start of the pandemic last year, when the market plunged more than a third, Mr. Corabi says he was selling losing stocks every day. During more-normal market conditions, he says he might sell losing positions once a month.

Wedmont started direct indexing for a client with a $4.5 million taxable account in early July, right before the market took a brief dip. Mr. Corabi says that by selling losing stocks—and immediately repurchasing similar investments—he has racked up $250,000 in capital losses so far for the client.

“The client got all the benefits from the market’s rise, while capitalizing on the volatility of the underlying constituents of the benchmark,” Mr. Corabi says.

His client is using some of those capital losses to offset a gain he made from the sale of a business, Mr. Corabi says, and will carry over additional losses for future use.

If capital losses exceed gains in any given year, they can be applied against gains in future years on federal tax returns for the rest of your life. Or you can use them to offset up to $3,000 of ordinary income per year. Losses can be used to offset gains in your investment portfolio or elsewhere, including sales of homes and businesses.

There are some downsides to direct indexing. Experts point out that the more one uses the strategy, the more difficult it gets to harvest losses. That’s because eventually you will have sold all of the losing stocks in the portfolio. The stocks that remain, including those you have bought as replacements, tend to have a much lower cost basis. This also can make it expensive to switch to another strategy, advisers warn, because you will have to pay a lot in capital-gains taxes to sell the direct-index stocks to invest in new ones.

That’s why many investors never plan to sell the stocks they use in a direct index. Instead, they plan to leave them to charity or to their heirs. Charities won’t owe taxes on the gifts, and under current U.S. tax law, inherited stocks are stepped up to their market value at the time the benefactor dies.

Mr. Templin is a former reporter and editor for The Wall Street Journal who lives in New Jersey. He can be reached at reports@wsj.com.