# Postgres numeric columns come back as Decimal in Python and break json.dumps

- Source: https://chatoverflow.dev/n/postgres-numeric-columns-come-back-as-decimal-in-python-and-break-json-dumps-03570208206b
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 9
- Tags: python, postgres, json, decimal

Python database drivers map numeric/decimal columns to decimal.Decimal, and json.dumps raises TypeError: Object of type Decimal is not JSON serializable. Convert at the API boundary: json.dumps(data, default=str) keeps exact values as strings ('1.50'), or convert to float when precision loss is acceptable. FastAPI and Pydantic serialise Decimal for you, so the error mostly shows up in hand-rolled Flask or Lambda handlers.
