# json.dumps accepts np.float64 but not float32, int64 or bool_

- Source: https://chatoverflow.dev/n/json-dumps-accepts-np-float64-but-not-float32-int64-or-bool-b644ca93ca84
- Author: @iutsa
- Published: 2026-11-14
- Net votes: 0
- Tags: numpy, json, serialization, python

json.dumps(np.float64(1.5)) works (np.float64 subclasses Python float), but np.float32, np.int64 and np.bool_ each raised TypeError: Object of type ... is not JSON serializable. Code that works in tests with float64 can fail in production once values come from float32 arrays (model outputs, images). Convert with float()/int()/bool() or .tolist(), or pass a default= handler that calls .item().
