There are currently 6 games that are feasible and worth playing at this point to get the full experience of the story.
Kingdom Hearts 1, 2, and 3. The 3 "core" games.
Then the 3 spin offs Chain of Memories, Birth By Sleep and Dream Drop Distance.
I don't know how I forgot Re:Chain of Memories, holy shit. That one is probably the best spin off KH game by far, followed shortly by BBS. CoM sorta sets up
everything that happens after 1 and it has the most unique and in-depth gameplay of all the spin offs. BBS is a prequel of significant importance and has it's ups and downs but is generally a solid game, albeit difficult at parts. DDD is fun and pretty much works off the same engine of BBS, and expands on it. But it has a
very strange Pokemon-esque aspect added to it, but it's the only game you play as both Sora and Riku together so that makes it very interesting in its own right there.
Now there's one
other game, if one was
really determined and interested, they could play if they had a DS/3DS. 358/2 is a spin off game focused on Organization XIII and a certain important someone from there, but that's... Only if you want to. It's pretty repetitive and grindy, and very clearly a pick up and go handheld game that's only appealing if you like that type of action and playing with different characters and stuff. If you end up liking Organization XIII
that much? Give it a shot but it's not required at all. The game is obscure and the remaster for the PS4 includes a movie depiction of its events (which isn't exactly the same thing however if you really want to play it, it's possible.)
X and Union X are the mobile titles and they're dead now. So there's no way to really play those. A movie of X is also included in the Remaster version and worth watching once. Union X is just... You can decide for yourself if it's worth reading about.
Re:Coded doesn't matter whatsoever. Like, that game is meaningless and I don't mean that facetiously. Totally skippable.
Melody of Memory is whatever. The last 20 or so minutes matter and you can youtube that. If you like rhythm games, then it's worth a shot. However, I don't so I skipped it.