SmartQueryTools

Round Numbers in JSON Files Online

Round numeric columns in JSON files to any number of decimal places directly in your browser. Set precision per column with a simple slider — no upload required.

How to round Numbers in JSON files

  1. Drop your file onto the upload area. Every numeric column is listed with its type, ticked, and set to 2 decimal places.
  2. Untick columns you want to leave alone, such as IDs, or use the All and None links.
  3. Drag each column's slider to set its decimal places, from 0 to 6. Each column can have its own setting.
  4. Click Round, check the preview of the first 200 rows, and download the file in the same format.

Your file is processed locally in your browser and is never uploaded. The free limit is 50 MB per file; larger files work if your device has the memory for them.

Worked example

A rainfall log from regional weather stations carries GPS coordinates to five decimals and rainfall to three. A public dashboard only needs about 100 m accuracy and one decimal of rain.

Input (JSON)

[
  {
    "station": "Kelburn",
    "lat": -41.28496,
    "lon": 174.76785,
    "rain_mm": 12.46
  },
  {
    "station": "Ohakea",
    "lat": -40.20611,
    "lon": 175.38872,
    "rain_mm": 0.05
  },
  {
    "station": "Paraparaumu",
    "lat": -40.90431,
    "lon": 174.98556,
    "rain_mm": 3.349
  },
  {
    "station": "Masterton",
    "lat": -40.97512,
    "lon": 175.63089,
    "rain_mm": null
  }
]

Settings

  • lat: 3 decimal places
  • lon: 3 decimal places
  • rain_mm: 1 decimal place

Result

stationlatlonrain_mm
Kelburn-41.285174.76812.5
Ohakea-40.206175.3890.1
Paraparaumu-40.904174.9863.3
Masterton-40.975175.631NULL

Each column is rounded to its own number of places. Halves round away from zero, so 0.05 becomes 0.1 and -41.28496 becomes -41.285. Masterton has no reading and stays empty. The station column is text and is not listed. Rounding changes the stored value, not just the display.

Working with JSON files

JSON numbers load as integers or doubles, and only keys that hold numbers in every object are listed. A key where some objects have "12.5" in quotes is not treated as numeric. Rounding is useful for JSON built by scripts that print full floating-point output, such as 0.30000000000000004, which bloats API payloads and test fixtures. Integer keys such as counts are listed too, but no setting changes a whole number.

Rounded values are written as JSON numbers without trailing zeros, so 3.30 becomes 3.3 and 4.00 becomes 4. Consumers that compare numbers numerically will not notice. Snapshot tests that compare text will. Objects missing a numeric key keep null for it. Nested objects are not listed and cannot be rounded here. Flatten the file first if the value you need is inside a nested object such as stats.mean. Keys that were not rounded are written back unchanged, in their original order.

Frequently Asked Questions

Why does 4.00 become 4 in my rounded JSON?

JSON numbers have no fixed number of decimals, so trailing zeros are dropped when the file is written. The value is the same.

Can I round numbers inside nested JSON objects?

Not directly. Only top-level numeric keys are listed. Flatten the JSON first, round the flat columns, then use the result.

How are halves rounded?

Away from zero. 2.5 rounds to 3 and -2.5 rounds to -3 at 0 places. This matches Excel's ROUND, not the banker's rounding used by some programming languages.

Can I round down, round up, or truncate instead?

No. The tool only does standard rounding. For floor, ceiling or truncation, use the SQL workspace with floor(), ceil() or trunc().

Can I round to the nearest 10 or 100?

No. The slider runs from 0 to 6 decimal places. To round to tens or hundreds, use round(x, -1) or round(x, -2) in the SQL workspace.

Related Tools