[jq] Round numbers down or up with floor and ceil

Created on November 30, 2026

You can use floor and ceil to round numbers to integers.

Round down with floor

floor returns the greatest integer less than or equal to its input. This example rounds each array element.

printf '%s\n' '[1.2,1.8,-1.2,-1.8]' | jq 'map(floor)'
[
  1,
  1,
  -2,
  -2
]

Round up with ceil

ceil returns the least integer greater than or equal to its input.

printf '%s\n' '[1.2,1.8,-1.2,-1.8]' | jq 'map(ceil)'
[
  2,
  2,
  -1,
  -1
]

The same rules apply to negative values. For -1.2, floor returns -2 and ceil returns -1.

Reference

jq