Float Precision

February 8, 2026 ยท View on GitHub

Controls how many decimal points to use when serializing floats and doubles.

[Fact]
public void FloatPrecision()
{
    var numbers = new List<object>
    {
        1.1234567f,
        1.1234567d,
    };

    var json = JsonConvert.SerializeObject(
        numbers,
        new JsonSerializerSettings
        {
            FloatPrecision = 3
        });
    Assert.Equal("[1.123,1.123]", json);
}

snippet source | anchor