The invention discloses an online density measurement method and device of a petroleum transmission pipeline. The online density measurement device is characterized in that one section of process main pipeline (6) with a constant-temperature electric tracing and insulating function (17) is serially connected to a bypass pipeline arranged on a pipeline to be measured, and the inlet end and the outlet end of the process main pipeline (6) are respectively controlled by process valves. Starting from the process valve (13) at the inlet end of the process main pipeline (6), oil flowing through the process main pipeline (6) is sequentially subjected to the following flows of: 1, filtering and draining; 2, measuring of pressure difference of two filtering ends; 3, flow testing; 4, manual sampling; 5, online checking; 6, pressure detecting; 7, draining; 8, sampling of a sampling pump (3); 9, online checking; 10, heat expansion safety protecting; 11, online density detecting; 12; exhausting; 13, processing of an intelligent pressure transformer; and 14, pressure difference measuring, flow detecting, sampling, online density detecting, and sending of signals to an apparatus junction box (16) and then an SCADA (Supervisory Control And Data Acquisition) system by the intelligent pressure transformer.