At present, real-time online measurement of fluid density is of great significance to improve the automation level of petrochemical and food industries. The tuning fork density sensor is widely used because of its characteristics of real-time online measurement, high measurement accuracy, simple structure, and convenient use. The traditional tuning fork density sensor in the market has the disadvantage of low resolution and being susceptible to liquid viscosity, which makes the sensor’s measurement accuracy low and not suitable for the measurement of high-viscosity liquid density. The measurement resolution and antiviscosity interference capability of the tuning fork density sensor are two major indexes to measure the measurement performance of the sensor, among the antiviscosity interference capability refers to the degree to which the measurement results of the sensor are affected by viscosity properties. However, the structural design of the tuning fork density sensor results in the conflict between the measurement resolution and the antiviscosity interference capability of the sensor, and the improvement of one performance is bound to affect the performance of the other. Aiming at the problem of how to balance the measuring performance of the tuning fork sensor, a density calculation model based on viscosity compensation is proposed in this paper. By studying the working principle and structure design of the tuning fork, the vibration characteristics of tuning fork in liquid with different viscosities and densities are modelled and simulated. From the results of simulation analysis, the better set of dimensions with balanced measuring performance is selected. Not only does the structure of the tuning fork have the characteristics of high resonance frequency, but also the measured results are less affected by the viscosity of the liquid. To solve the problem that density measurement is still affected by high-viscosity liquid after tuning fork dimension optimization, in this paper, the partial least square model is used to fit the experimental data of the frequency-density characteristics; then, the density calculation model based on the viscosity compensation is obtained by combining the frequency-viscosity characteristic experiment. Finally, through the performance test experiment comparing with the traditional tuning fork density sensor, the measurement resolution of the improved tuning fork density sensor is as high as 0.0001 g/cm3; within the viscosity range of 180 MPa·s, the accuracy reached ±0.001 g/cm3, and within 480 MPa·s, the measurement accuracy reached ±0.002 g/cm3. When the liquid viscosity reaches more than 10 MPa·s, the improved tuning fork density sensor has better overall measurement performance than the traditional tuning fork density sensor, and both of its measurement resolution and antiviscosity interference capability have been greatly improved.