Prison inmates lose many of their civil rights. But the Eighth Amendment to the U.S. Constitution (which prohibits “cruel and unusual punishment”), other federal laws, and state laws ensure that they don’t lose all of them.
Prison inmates retain rights to basic freedoms like freedom of speech and religion, and equal protection of law, meaning a right not to be treated differently than other prisoners based on characteristics such as race, sex, or religion (see Does the right to equal protection mean that all prisoners must be classified alike?). Prisoners also have the right to basic—albeit minimum—living standards. However, prisons may curtail these rights to some extent in the name of safety, order, and security. Courts tend to uphold prison rules that limit prisoners’ exercise of constitutional rights as long as the rules are reasonably related to legitimate prison needs.
For further reading, see How do courts determine whether prison conditions are cruel and unusual?