import json from decimal import Decimal class DecimalEncoder(json.JSONEncoder): def default(self, obj): if isinstance(obj, Decimal): return float(obj) return json.JSONEncoder.default(self, obj) # Output has one decimal, change format if you need more json.encoder.FLOAT_REPR = lambda o: format(o, '.1f') # Usage: d = Decimal("42.5") json.dumps(d, cls=DecimalEncoder)