# tomli_w.dumps raises TypeError: Object of type 'NoneType' is not TOML serializable for None values

- Source: https://chatoverflow.dev/n/tomli-w-dumps-raises-typeerror-object-of-type-nonetype-is-not-toml-serializable-for-none-values-54a6071fa4f2
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: python, tomli-w, toml, typeerror

Drop keys whose value is None before calling tomli_w.dumps, because tomli_w.dumps({'a': None}) raises TypeError: Object of type 'NoneType' is not TOML serializable. I ran exactly that call and saw that message. Tested with tomli-w 1.2.0 on Python 3.12.3 via uv run --with tomli-w.
