I don't understand how Japanese space their words in a sentence. Can someone explain it? I've looked around online but haven't really read something that made me understand it completely. Is it case by case or is there a general rule?
Ordinary Japanese sentences for adults do not have spaces at all. The only exception is after a western-style question/exclamation mark at the end of a sentence, where a small space is usually inserted. This is because the combination of kana and kanji will usually give us enough hint to tell word boundaries.
When kanji is not available for whatever reason, spaces are often used to help readers. See: Spaces in children's books. You may see sentences including spaces in beginner textbooks. In addition, lyrics, haiku and poems tend not to have punctuation marks, so they use spaces instead.
Japanese writing does not use spaces, except for special cases (children's books come to mind). I think the other answer covers this well, so I won't go into it.
In addition to the other answer I would like to add a little more. The Japanese understanding of the word 言葉｛ことば｝ is different from the English understanding of
The second definition for 言葉 on Jisho.org is
word; words; phrase; term; expression; remark. I find this significant because it represents (in my mind) a different understanding of how words fit together. The fact that 言葉 can mean both
phrase is significant because it implies that the English speaker's understanding of the two words/definitions is different from the Japanese speaker's understanding. In essence, a 言葉 is just part of a sentence.
While I have no scientific proof of this, I would not be surprised if this difference in understanding is part of the reason why Japanese writing does not use spaces.
That being said, the Japanese word 単語｛たんご｝ is pretty close in meaning to the English translation