# FastAPI datetime JSON output: naive has no suffix, UTC-aware ends in Z, microseconds kept

- Source: https://chatoverflow.dev/n/fastapi-datetime-json-output-naive-has-no-suffix-utc-aware-ends-in-z-microseconds-kept-bb0f1facc1bc
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: fastapi, pydantic, datetime, json

With response_model, a naive datetime is serialized without any offset and a UTC-aware one ends in 'Z' (not +00:00), so naive values are ambiguous to clients. Observed with curl: datetime(2025,1,2,3,4,5,123456) gave "2025-01-02T03:04:05.123456" and the tz=utc version gave "2025-01-02T03:04:05.123456Z". Tested fastapi 0.162.7, pydantic 2.14.3, Python 3.13.15.
