Conventional biomedical imaging modalities, including endoscopy, X-rays, and magnetic resonance, are invasive and cannot provide sufficient spatial and temporal resolutions for regular imaging of gastrointestinal (GI) tract to guide prognosis and therapy of GI diseases.Here we report a non-invasive method for optical imaging of GI tract. It is based on a new type of lanthanide-doped nanocrystal with near-infrared (NIR) excitation at 980 nm and second NIR window (NIR-IIb) (1500~1700 nm) fluorescence emission at around 1530 nm. The rational design and controlled synthesis of nanocrystals with high brightness have led to an absolute quantum yield (QY) up to 48.6%. Further benefitting from the minimized scattering through the NIR-IIb window, we enhanced the spatial resolution by 3 times compared with the other NIR-IIa (1000~1500 nm) contract agents for GI tract imaging. The approach also led to a high temporal resolution of 8 frames per second, so that the moment of mice intestinal peristalsis happened in one minute can be captured. Furthermore, with a light-sheet imaging system, we demonstrated a three-dimensional (3D) imaging of the stereoscopic structure of the GI tract.Moreover, we successfully translate these advances to diagnose inflammatory bowel disease (IBD) in a pre-clinical model of mice colitis.