Skip to content

Floats in JSON.parse are converted into integers #61704

@samsoul007

Description

@samsoul007

Version

v25.6.0 / v25.4.0

Platform

Docker local MacOs. 
Docker image: 
node:latest / node:25.4.0

Edit:
It seems to work as expected when doing:
docker run -it --rm node:25.6.0

It breaks on my system (Apple M1 Pro/ MACOs15.5 (24F74)) when doing:
docker run --platform linux/amd64 -it --rm node:25.6.0

Subsystem

No response

What steps will reproduce the bug?

Just run the node command in CLI and try parsing a float.

root@17ebd2a1a753:/app# node
Welcome to Node.js v25.6.0.
Type ".help" for more information.

JSON.parse('{"x": 10.3342}')
{ x: 10 }

How often does it reproduce? Is there a required condition?

N/A

What is the expected behavior? Why is that the expected behavior?

Should retain the decimals

JSON.parse('{"x": 10.3342}')
{ x: 10.3342 }

What do you see instead?

Converts into Integer:

JSON.parse('{"x": 10.3342}')
{ x: 10 }

Additional information

I think it is only on v25. v24 is working as intended.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions