It depends. In PA the whole amount would be considered basis for state only because there is no income deduction for contributions to these plans. If you lived in Pennsylvania (PA) when the funds were contributed to either a 401(k) or IRA, then none of the distribution is taxable if you are retirement age.
PA does not allow a deduction for these contributions when you work which is why they are tax free at retirement. The same rules apply to the Roth IRA in PA.
However, if you are not retirement age, then only the earnings that were withdrawn/distributed are taxable to PA.
If you did not live in PA when you made contributions, and you live there now and retired, none of the retirement income is taxable.
For federal purposes, none of it would be considered a cost basis for any amounts you were allowed to deduct or contribute tax free such as your 401(k) and possibly the IRA. The Roth IRA is not taxable for federal purposes if taken after 5 years from establishment and you are at retirement age.
Please update if you have more questions and we will help.
@covert-eric
**Say "Thanks" by clicking the thumb icon in a post
**Mark the post that answers your question by clicking on "Mark as Best Answer"