Rail spacing & Child proofing a deck
I did a google search and turned up one recommendation for a maximum 4 inch spacing. That sounds right to me, and is in accordance with the International Residential Code for One- and Two-Family Dwellings.


  R312.3 Opening limitations. Required guards shall not have openings
  from the walking surface to the required guard height which allow
  passage of a sphere 4 inches (102 mm) in diameter.