> For the complete documentation index, see [llms.txt](https://docs.datajet-app.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.datajet-app.com/liquid/filters/decrement.md).

# decrement

Subtracts one from a number. Sugar for `| minus: 1`.

```liquid
{% assign remaining = remaining | decrement %}
```

## Syntax

```liquid
{{ value | decrement }}
```

| Parameter | Description                     |
| --------- | ------------------------------- |
| `value`   | The number to subtract one from |

## Return Value

Returns the value minus one. Identical to `| minus: 1`.

## Examples

**Count down remaining retries:**

```liquid
{% assign retries = 3 %}
{% while retries > 0 %}
  {% http url: endpoint, method: "GET" as res %}
  {% if res.ok %}{% break %}{% endif %}
  {% assign retries = retries | decrement %}
{% endwhile %}
```

**Reduce stock in a payload:**

```liquid
{% assign available = variant.inventory_quantity | integer: 0 | decrement %}
```

## Notes

* Exactly `| minus: 1`, including its coercion: non-numeric input yields `NaN`. Cast first with `integer` if the input may be text
* Not the same as the `{% decrement %}` **tag**. The filter returns a new value and leaves the variable alone; the tag subtracts one from the variable in place and outputs nothing
* See also: `increment`, `minus`, the `{% decrement %}` tag
