Carbon dots (CDs) has been widely utilized in multiple fields, especially towards kinds of drug analyses, owing to its superior optical properties and satisfactory stability. Herein, we rapidly synthesized one kind of soluble bright-blue fluorescent CDs through a facile microwave method, while disodium ethylenediaminetetraacetic acid and phosphoric acid served as the raw materials. Importantly, introducing ranitidine into these CDs resulted in its decreased fluorescence, and thus an innovative method of detecting ranitidine was successfully established, which showed the favorable selectivity and anti-interference ability. Moreover, with the optimal conditions, the standard curve of F0/F against concentrations of ranitidine exhibited the generally satisfactory linear range of 6-2000 µM with a correlation coefficient of 0.9833, and the limit of detection (LOD) was calculated to be 4.2 µM. Meanwhile, we also explored the detecting mechanism of ranitidine by CDs, and elaborated that as the internal filtration effect. Consequently, we may broaden the avenues of detecting ranitidine on the basis of CDs.