Prevent item stacking using commands

Since you asked for "a command", you probably mean one. That simply isn't possible. There's no command that does this.

You could build a big command block system that either deletes items that are in stacks of 2+ or spreads them out (which would be problematic in a full inventory) or whatever. But that's a major project, not one command. And it wouldn't work that nicely.

If you just need a few types of items to be unstackable, you can just use unstackable items and, if you need to, retexture them to look like other items (and change the name in the language file). These are the unstackable items:

  • all tools
  • all weapons
  • all player and horse armor
  • shield
  • all filled buckets (including fish)
  • saddles
  • all minecarts
  • all boats
  • compass
  • clock
  • filled maps (can't be retextured)
  • potions (many different textures possible)
  • written book
  • enchanted books
  • elytra
  • all shulker boxes
  • all records
  • all banners and banner patterns
  • rabbit stew, mushroom soup and suspicious stew

Keep in mind that the players can still use the items like normal, even if you retexture and rename them. So you would either want to give them items they can't use (like a clock) or prevent them from using the items in some other way.