Cysteine cathepsins often contribute to cancer progression due to their overexpression in the tumour microenvironment and therefore present attractive targets for non-invasive diagnostic imaging. However, the development of highly selective and versatile small molecule probes for cathepsins has been challenging. Here, we targeted tumour-associated cathepsin B using designed ankyrin repeat proteins (DARPins). The selective DARPin 8h6 inhibited cathepsin B with picomolar affinity (Ki = 35 pM) by binding to a site with low structural conservation in cathepsins, as revealed by the X-ray structure of the complex. DARPin 8h6 blocked cathepsin B activity in tumours ex vivo and was successfully applied in in vivo optical imaging in two mouse breast cancer models, in which cathepsin B was bound to the cell membrane or secreted to the extracellular milieu by tumour and stromal cells. Our approach validates cathepsin B as a promising diagnostic and theranostic target in cancer and other inflammation-associated diseases.