How to write that I have two kids one is 5 years old and the other is 8 months old ?
It is ok, but you can phrase it better that ‘the other’ it somehow doesn’t sound great especially in writing when we talk about people.
When you say : they are 5 years old and 8 months old it is not really semantically correct as ‘are’ refers to both kids and ages. Therefore, you should use ‘ respectively’.
I have two kids, they are 5 years old and 8 months old, respectively.
If they are of different genders and you don’t mind sharing it, the best would be, eg.:
I have two kids, a 5-year-old girl and an 8-month-old boy.
You can also say-
I have two kids, a 5-year-old and an 8-month-old.
( here 5-year-old / 8-month-old are used as nouns and when you say it , you pronounce it as one word)
This one is probably the most idiomatically common: My 5-year-old is really quiet but my 1-year-old is full of energy.