The biological sciences community is increasingly recognizing the value of open, reproducible, and transparent research practices for science and society at large. Despite this recognition, many researchers remain reluctant to share their data and code publicly. This hesitation may arise from knowledge barriers about how to archive data and code, concerns about its re-use, and misaligned career incentives. Here, we define, categorise, and discuss barriers to data and code sharing that are relevant to many research fields. We explore how real and perceived barriers might be overcome or reframed in light of the benefits relative to costs. By elucidating these barriers and the contexts in which they arise, we can take steps to mitigate them and align our actions with the goals of open science, both as individual scientists and as a scientific community.