Science thrives on reproducibility. In the politicized realm of the climate sciences, for example, it has long been good practice to have three independent reconstructions of the global temperature record1,2,3. And still, when a fourth one appeared4, largely confirmatory of the existing three, it was greeted with a media storm — mainly because the authors had emphasized their independence of the entire climate science community in the run-up to the announcement of their work5.

Two ingredients are essential for reproducibility in any field in science: full disclosure of the methods used to obtain and analyse data, and availability of the data that went into and came out of the analysis. Data disclosure has long been one of our policies. To help with the second aspect, the Nature family of journals is now introducing a policy on computer code: we strongly encourage sharing of code and consider it best practice wherever possible. When code is central to obtaining the results presented in a paper, we now require a statement about code availability in the Methods section of our papers, which must include information on how to obtain code and a description of any limitations to its availability.

Sharing code is not always simple. As argued in a Commentary on page 779 in this issue, complex code such as that used in global climate models cannot easily be used by others in a meaningful way. In general, substantial effort is required to make a complex piece of software run on a different machine, and in some cases, it may not be possible. There can also be other technical, legal and commercial restrictions to code sharing. In recognition of these difficulties, Nature journals do not mandate that code be made fully available, and instead only require that the underlying equations be published in sufficient detail to allow reproducibility6. But we strongly encourage authors to make their code available where possible, both to make it as clear as possible to readers exactly what was done, and to allow others to build on their work.

Issues around data sharing have been in the spotlight longer. The benefits of sharing data, not only for scientific progress, but also for the careers of individuals, are slowly being recognized. Nevertheless, more incentives are needed to encourage researchers to transfer their private data archives to public repositories together with all the necessary metadata, as suggested in a Commentary on page 778 in this issue.

Making fully annotated, high-quality data publicly available for re-use already brings recognition, citations and professional collaborations to individuals, and much faster progress to science. Many of these benefits could equally apply to code sharing, once it is established as best practice, and fully recognized as part of the scientific endeavour. We are hoping that our code-sharing policy will pave the way.