Heparin is an important anticoagulant in clinics, which requires regular detection and dose adjustment. Fluorimetry is a powerful tool considering the advantages of fast response and high sensitivity while most fluorescent sensors suffer from spontaneous fluorescence for excitation under short-wavelength light, the occurrence of false positives, complex and time-consuming preparation, as well as expensive detection instruments. Herein, we developed upconversion nanoparticles (UCNPs) based nanosensor for fluorescent and colorimetric detection of heparin. The nanosensor exhibited sensitive detection for heparin with the low limit of detection (LOD) of 0.1 nM in fluorescent mode and 0.3 nM in colorimetric mode. In addition, we used a smartphone-sensing platform for quantitative detection of heparin with the LOD of 2 nM. Depending on long-wavelength excitation and fluorescent-colorimetric dual-response detection signal, the designed nanosensor could eliminate the auto-fluorescence, which effectively increased the accuracy of the sensor, thus extending the applications for bed-side heparin assay and related medical safety.