As a general rule roofs that have a high human occupancy rate should be framed with rafters every 16 structures such as sheds or barns can be frames with rafters every 24 again make sure to consult local codes.
Shed roof joist size.
More roof calculators roof truss calculator.
For heavy loads 2x4s can span up to 5.
2 4 rafters can span up to 7.
2x8s are used frequently for these projects.
Rafter and joist span faq.
The lengths and sizes of joists vary depending on the species and quality of the lumber used.
Most roof framing is 24 on center and you can still build sheds up to 14 with 2 4 rafters at 24 on center.
In other words if there is a 1 1 2 ridge board nailed into the wall and the width of the lean to is 96 then the run will be 94 1 2 96 1 1 2 94 1 2.
To size joists and rafters use the maximum span tables for southern yellow pine.
For light load roofs 24 o c.
However the timber sizes you have opted for will prove to be an issue.
In many circumstances 16 inches would be your standard spacing for shed floor joist but this is just a rough guideline.
The run for a lean to shed rafter ending into a wall should account for the ridge board nailed into the wall where the tops of the rafters rest into.
This is based upon the span of the rafter horizontal span not total rafter length live and dead loads.
If your project had a rafter length of 8 or less a safe and strong method is to use 2x8 framed 16 on center.
For example you can span a 1 grade no knots southern yellow pine a greater distance than a 2 grade with knots southern yellow pine.
This is due to the fact that the timber is 5mts long.
This is the distance between joist centres.
For example in the rafter span table below the highlighted cell in the 40 live load table indicates that 2 x 8 southern yellow pine joists that have a grade of 2 that are spaced 24 apart can have a maximum span of 10 feet 3 inches 10 3 if designing for a live load of 40 lbs ft 2.
This rafter span calculator is species specific for douglas fir hemlock etc.
The fact that they are 2x4 will mean that the timber will become curved within 2 years from the weight.
Trying to find what size lumber to use.
Usually 400 450 or 600mm but any value can be used up to 610mm max usually 400 450 or 600mm but any value can be used up to 610mm max 1 2 timber strength class and joist size.
Two options that arise could be your wider 24 and your narrower 12 options for spacing.