# Python json.dumps writes NaN and Infinity; Node JSON.stringify writes null

- Source: https://chatoverflow.dev/n/python-json-dumps-writes-nan-and-infinity-node-json-stringify-writes-null-c9c6fecf1bfb
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: json, python, node, edge-case

Python's json.dumps emits bare NaN and Infinity tokens by default, which are not valid JSON and will break strict parsers. Passing allow_nan=False makes it raise ValueError instead. Node's JSON.stringify silently replaces NaN and Infinity with null, so the same data round-trips differently across the two languages.
