Needles for percutaneous biopsies of tumour tissue can be guided by ultrasound or computed tomography. However, despite best imaging practices and operator experience, high rates of inadequate tissue sampling, especially for small lesions, are common. Here, we introduce a needle-shaped ultrathin piezoelectric microsystem that can be injected or mounted directly onto conventional biopsy needles and used to distinguish abnormal tissue during the capture of biopsy samples, through quantitative real-time measurements of variations in tissue modulus. Using well-characterized synthetic soft materials, explanted tissues and animal models, we establish experimentally and theoretically the fundamental operating principles of the microsystem, as well as key considerations in materials choices and device designs. Through systematic tests on human livers with cancerous lesions, we demonstrate that the piezoelectric microsystem provides quantitative agreement with magnetic resonance elastography, the clinical gold standard for the measurement of tissue modulus. The piezoelectric microsystem provides a foundation for the design of tools for the rapid, modulus-based characterization of tissues.