A new method to measure the viscosity of non-Newtonian fluids over a wide range of shear rates in a short period of time is presented. The technique is based on the measurement of the velocity profile in a pipe flow using ultrasound Doppler velocimetry (UDV), which is a non-invasive method, and simultaneously determining the pressure drop. The velocity profile is used to obtain shear rate distribution, while the pressure drop is used to calculate the shear stress distribution. By taking the ratio of these quantities at a radial position, local viscosity can be obtained within the shear rate range in the flow, zero at the center, and maximum at the wall, within minutes. For comparison purposes, viscosity of xanthan gum solutions with concentrations of 0.6 and 1.0 kg/m(3) are also measured using a conventional technique and the agreement between the results is satisfactory. Therefore, this technique shows promise for use as an online viscosity sensor for production processes.