I am replacing the deck and the existing railing isn't to code. Can I replace the existing railing if I don't alter the plan or do I have to build to code?
Well you probably could just replace the railing if without any building inspector coming by to verify this but you should do it properly.
It's the honor system for renovation work in existing construction and a small job like that is generally not noticed. With new construction the inspectors are there at every phase making sure jobs are done right.
All of this said, build it properly for your own safety. The code in Ontario is a bit different than in the US. In Ontario if your deck is 1.8m (5'-10") above grade the rail has to be 42" high. Whereas in the US, any residential setting the rail must be 36".
So make sure the top rail is 42" high. If you are less than 1.8m but at least 60cm (2') above grade then you need a 36" high rail. Both scenarios require a rail to pass a point load of 224 lbs (1.0 kN)and a uniform (distributive) load of 34 plf (0.5 kN/m). Ontario requires a safety factor of 1.5x for wood rails so those numbers go up to 336 lbs and 51 plf.
Keep in mind the spaces between balusters can't be more than 4" and the space from the deck to underside of the bottom rail can't be more than 4" either.
I won an inflatable 6 person inter hot tub. I have a large deck. 12x 20 on both sides of the house. With a header to the house and the deck was built 6
I'm putting a swim spa into an inground concrete bunker and will build a deck around it. I have been advised to keep the deck joists a minimum of 6 inches