Would you write 5-year-old or 5 year olds?

"5-year-old" is correct.

When the age is used as an adjective before a noun, there is no "s". For example, "a 5-year-old child".

On the other hand, when the age is used on its own, without a noun, "s" is usually added. For example, "The 5-year-olds are playing in the playground."

Pediatrics - Related Articles