Why is JsonUtility.ToJson turning all my floats into doubles?

In the long run my save games end up storing thousands of floats as some players run around for 100+km. In trying to further optimize the save files I’m finding that all of the floats have 15-16 digits. Which is way more precision than I need, and when multiplied thousands of times ends up being a lot more data than I need. Is this expected behavior?

Json uses the double precision floating-point format for numbers. There’s no way to change that. As alternative you can store your value as string and format it any way you like. Though you have to do the conversion to \ from string yourself.

Alternate way(hoping this helps someone):

using Newtonsoft.Json; // use this namespace

JsonConvert.SerializeObject(object); //use this line of code to change a object to json string

this works the same way as JsonUtility.ToJson(object) except it doesn’t change the float precision.