[jq] Generate a sequence of numbers with range

Created on November 30, 2026

Use range to generate numbers between a starting value and an exclusive upper bound.

jq -n 'range(1; 4)'
1
2
3

The default step is 1. The -n option runs the filter without reading input JSON.

Set a step and collect the values in an array

The third argument controls the step. Wrap the filter in brackets to collect its results as a single array.

jq -n '[range(0; 10; 2)]'
[
  0,
  2,
  4,
  6,
  8
]

Here the sequence starts at 0 and advances by 2 until it reaches the upper bound of 10.

Reference

jq