Skip to main content
Skip table of contents

Number Filters

LAST UPDATED: DECEMBER 10, 2025

abs

Returns the absolute value of the piped input number.

Examples - abs

EXAMPLE 1

Input:

CODE
{{ -5 | abs }}

Return Data:

TEXT
5

EXAMPLE 2

Input:

CODE
{{ 1.5 | abs }}

Return Data:

TEXT
1.5

EXAMPLE 3

Input:

CODE
{{ ' -1 ' | abs }}

Return Data:

TEXT
1

EXAMPLE 4

Input:

CODE
{{ ' ' | abs }}
{{ '' | abs }}

Return Data:

TEXT
0
0

EXAMPLE 5

Input:

CODE
{{ [ -1, -2 | abs, -3 ] }}

Return Data:

TEXT
[
  -1,
  2,
  -3
]

EXAMPLE 6

Input:

CODE
{{ {'x': -7 | abs, 'y': 3} }}

Return Data:

TEXT
{
  "x": 7,
  "y": 3
}

at_least(minimum_limit)

Returns the numeric value of the piped input when it is greater than or equal to the minimum limit, or returns the minimum limit when it is not.

Examples - at_least

EXAMPLE 1

Input:

CODE
{{ 2 | at_least(1) }}

Return Data:

TEXT
2

EXAMPLE 2

Input:

CODE
{{ -3 | at_least(0) }}

Return Data:

TEXT
0

EXAMPLE 3

Input:

CODE
{%  set obj = {'x':-3.7} %}
{{ obj.x | at_least(-3.8) }}

Return Data:

TEXT
-3.7

at_most(maximum_limit)

Returns the numeric value of the piped input when it is less than or equal to the maximum limit, or returns the maximum limit when it is not.

Examples - at_most

EXAMPLE 1

Input:

CODE
{{ 2 | at_most(1) }}

Return Data:

TEXT
1

EXAMPLE 2

Input:

CODE
{{ -3 | at_most(0) }}

Return Data:

TEXT
-3

EXAMPLE 3

Input:

CODE
{%  set obj = {'x':-3.7} %}
{{ obj.x | at_most(-3.8) }}

Return Data:

TEXT
-3.8

ceil(decimal_places)

Returns the input number rounded upward to the specified number of decimal places.

Examples - ceil

EXAMPLE 1

Input:

CODE
{{ 1.234 | ceil(2) }}

Return Data:

TEXT
1.24

EXAMPLE 2

Input:

CODE
{{ 1.90 | ceil(1) }}
{{ 1.91 | ceil(1) }}

Return Data:

TEXT
1.9
2

EXAMPLE 3

Input:

CODE
{{ 2.19000 | ceil(2) }} 
{{ 2.19001 | ceil(2) }} 

Return Data:

TEXT
2.19
2.2

EXAMPLE 4

Input:

CODE
{{ -1.999 | ceil(0) }}
{{ -1.999 | ceil(1) }}

Return Data:

TEXT
-1
-1.9

EXAMPLE 5

Input:

CODE
{{ 0 | ceil(5) }}

Return Data:

TEXT
0

check_type(data)

Determines the data type of the provided value or variable. Supported types include:

  • array (list)

  • BlockReference

  • Boolean (bool)

  • bytes

  • Cycler

  • dictionary / object (dict)

  • float

  • integer (int)

  • Joiner

  • LoopContext

  • Macro

  • Markup

  • Namespace

  • null / none (NoneType)

  • range

  • string (str)

  • TemplateReference

  • tuple

  • type

  • Undefined

Examples - check_type

EXAMPLE 1

Input:

CODE
{{ 42 | check_type }}

Return Data:

TEXT
int

EXAMPLE 2

Input:

CODE
{% set cert_text = "-----BEGIN CERTIFICATE-----MIIBsjCCARugAwIBAgIU...-----END CERTIFICATE-----" %}
{% set cert_bytes = cert_text.encode("utf-8") %}
{{ cert_bytes | check_type }}

Return Data:

TEXT
bytes

EXAMPLE 3

Input:

CODE
{% set html_output = "<b>Alert Confirmed</b>" | safe %}
{{ html_output | check_type }} 

Return Data:

TEXT
Markup 

EXAMPLE 4

Input:

CODE
{% for i in [1, 2, 3] %}
  {{ loop | check_type }}
{% endfor %}

Return Data:

TEXT
LoopContext

LoopContext

LoopContext

default(default_value)

Returns a fallback value when the provided variable is undefined or empty. If the variable is defined, the original value is returned unchanged.

Examples - default

EXAMPLE 1

Input:

CODE
{% set num = 42 %}
{{ num | default("Variable is not defined.") }}

Return Data:

TEXT
42

Input:

CODE
{{ num | default("Variable is not defined.") }}

Return Data:

TEXT
Variable is not defined.

EXAMPLE 2

Input:

CODE
{% set alert = {"type": "Phishing Email", "severity": "high"} %}
{{ alert.severity | default("medium") }}

Return Data:

TEXT
high  

Input:

CODE
{% set alert = {"type": "Phishing Email", "severity": "high"} %}
{{ alert.non_existent_attribute | default("medium") }}

Return Data:

TEXT
medium

EXAMPLE 3

Input:

CODE
{{ arr | default("Array is not defined.") }}

Return Data:

TEXT
Array is not defined.  

divide_by(divisor)

Returns the numeric result of dividing the piped input by the divisor.

Examples - divide_by

EXAMPLE 1

Input:

CODE
{{ -1 | divide_by(2) }}

Return Data:

TEXT
-0.5

EXAMPLE 2

Input:

CODE
{{ [-3,-2,-1][2] | divide_by(-4) }}

Return Data:

TEXT
0.25

EXAMPLE 3

Input:

CODE
{% set obj = {'x':1,'y':2} %}
{{ obj.x | divide_by(3) }}

Return Data:

TEXT
0.3333333333333333

equals(value)

Returns a Boolean that indicates whether the piped input and the comparison value are equivalent in content. Supports comparison of numbers, strings, objects, and arrays.

Examples - equals

EXAMPLE 1

Input:

CODE
{{ 3 | equals(3) }}
{{ 3 | equals('3') }}
{{ '3' | equals(3) }}

Return Data:

TEXT
True
True
True

EXAMPLE 2

Input:

CODE
{% set alert1 = {
  "alert_id": "INC-48392",
  "threat_type": "phishing",
  "severity": "high",
  "source": "splunk"
} %}

{% set alert2 = {
  "alert_id": "INC-48392",
  "threat_type": "phishing",
  "severity": "high",
  "source": "splunk"
} %}

{{ alert1 | equals(alert2) }}

Return Data:

TEXT
True

EXAMPLE 3

Input:

CODE
{{ "D3Security" | equals("d3security") }}

Return Data:

TEXT
False

EXAMPLE 4

Input:

CODE
{% set baseline_hashes = [
  "b7f9a3d2e4c6f8b92a47d5c1aa12bb34ef9c8902e2345ab19f37da7c1234eac1",
  "9a81b02f4cc5b7a0fbc21c5a923e2d3aa87f02b5cc99e3311a9f7df25f91d2c4",
  "a7d2c09fbd11e3b9b4a56f9320e57dfb88e5fa17d0b14a7bcd90a0f7adcefa91"
] %}

{% set recent_hashes = [
  "b7f9a3d2e4c6f8b92a47d5c1aa12bb34ef9c8902e2345ab19f37da7c1234eac1",
  "9a81b02f4cc5b7a0fbc21c5a923e2d3aa87f02b5cc99e3311a9f7df25f91d2c4",
  "a7d2c09fbd11e3b9b4a56f9320e57dfb88e5fa17d0b14a7bcd90a0f7adcefa91"
] %}

{{ baseline_hashes | equals(recent_hashes) }}

Return Data:

TEXT
True

filesizeformat(is_binary)

Returns a human-readable file-size string, scaling the piped byte count to an appropriate unit. By default, the filter uses decimal units. When the parameter is set to True, the filter applies binary units.

Examples - filesizeformat

EXAMPLE 1

Input:

CODE
{{ 1 | filesizeformat }}  

Return Data:

TEXT
1 Byte

EXAMPLE 2

Input:

CODE
{{ 1000 | filesizeformat }} 

Return Data:

TEXT
1.0 kB

EXAMPLE 3

Input:

CODE
{{ 1e6 | int | filesizeformat }}  

Return Data:

TEXT
1.0 MB

EXAMPLE 4

Input:

CODE
{{ (10**9) | filesizeformat }}  

Return Data:

TEXT
1.0 GB

EXAMPLE 5

Input:

CODE
{{ (2**0) | filesizeformat(True) }}
{{ (2**10) | filesizeformat(True) }}
{{ (2**20) | filesizeformat(True) }}
{{ (2**30) | filesizeformat(True) }}

Return Data:

TEXT
1 Byte
1.0 KiB
1.0 MiB
1.0 GiB

floor(decimal_places)

Returns the piped numeric value rounded downward to the specified number of decimal places.

Examples - floor

EXAMPLE 1

Input:

CODE
{{ 1.234 | floor(2) }}

Return Data:

TEXT
1.23

EXAMPLE 2

Input:

CODE
{{ 2.01 | floor(1) }}
{{ 2.10 | floor(1) }}

Return Data:

TEXT
2
2.1

EXAMPLE 3

Input:

CODE
{{ 2.19999 | floor(2) }}
{{ 2.20001 | floor(2) }}

Return Data:

TEXT
2.19
2.2

EXAMPLE 4

Input:

CODE
{{ -1.001 | floor(0) }}
{{ -1.001 | floor(1) }}

Return Data:

TEXT
-2
-1.1

EXAMPLE 5

Input:

CODE
{{ 0 | floor(5) }}

Return Data:

TEXT
0

greater_or_equal(comparison_value)

Returns a Boolean indicating whether the piped numeric value is greater than or equal to the comparison value.

Examples - greater_or_equal

EXAMPLE 1

Input:

CODE
{{ 1 | greater_or_equal(3) }}

Return Data:

TEXT
False

EXAMPLE 2

Input:

CODE
{{ [2,3,4][1]  | greater_or_equal(3) }}

Return Data:

TEXT
True

EXAMPLE 3

Input:

CODE
{% set obj = {'x':100, 'y':101} %}
{{ obj.x | greater_or_equal(obj.y) }}

Return Data:

TEXT
False

greater_than(comparison_value)

Returns a Boolean indicating whether the piped numeric value is greater than the comparison value.

Examples - greater_or_equal

EXAMPLE 1

Input:

CODE
{{ 0 | greater_than(-1) }}

Return Data:

TEXT
True

EXAMPLE 2

Input:

CODE
{{ [1.1,1.2,1.3][1]  | greater_than(1.21) }}

Return Data:

TEXT
False

EXAMPLE 3

Input:

CODE
{% set obj = {'x':100, 'y':101} %}
{{ obj.y | greater_than(obj.x) }}

Return Data:

TEXT
True

less_or_equal(comparison_value)

Returns a Boolean indicating whether the piped input is less than or equal to the comparison value.

Examples - less_or_equal

EXAMPLE 1

Input:

CODE
{{ 0 | less_or_equal(0) }}
{{ 1 | less_or_equal(0) }}
{{ 0 | less_or_equal(1) }}

Return Data:

TEXT
True
False
True

EXAMPLE 2

Input:

CODE
{{ -1 | less_or_equal(0) }}
{{ -5 | less_or_equal(-5) }}
{{ -3 | less_or_equal(-5) }}

Return Data:

TEXT
True
True
False

EXAMPLE 3

Input:

CODE
{{ 1.1 | less_or_equal(2.2) }}
{{ 1 | less_or_equal(1.0) }}
{{ 0.000001 | less_or_equal(0.0) }}    

Return Data:

TEXT
True
True
False

less_than(comparison_value)

Returns a Boolean indicating whether the piped input is numerically less than the comparison value.

Examples - less_than

EXAMPLE 1

Input:

CODE
{{ 0 | less_than(0) }}
{{ 1 | less_than(0) }}
{{ 0 | less_than(1) }}

Return Data:

TEXT
False
False
True

EXAMPLE 2

Input:

CODE
{{ -1 | less_than(0) }}
{{ -5 | less_than(-5) }}
{{ -3 | less_than(-5) }}

Return Data:

TEXT
True
False
False

EXAMPLE 3

Input:

CODE
{{ 1.1 | less_than(2.2) }}
{{ 1 | less_than(1.0) }}
{{ 0.000001 | less_than(0.0) }}    

Return Data:

TEXT
True
False
False

minus(subtraction_value)

Returns the difference between subtracting the subtraction value from the piped input.

Examples - minus

EXAMPLE 1

Input:

CODE
{{ 3 | minus(2) }}
{{ 0 | minus(0) }}
{{ 1 | minus(0) }}
{{ 0 | minus(1) }}

Return Data:

TEXT
1
0
1
-1

EXAMPLE 2

Input:

CODE
{{ -1 | minus(1) }}
{{ -5 | minus(-3) }}
{{ -3 | minus(-5) }}

Return Data:

TEXT
-2
-2
2

EXAMPLE 3

Input:

CODE
{{ 1.5 | minus(0.5) }}
{{ 0.5 | minus(1.5) }}
{{ 1.5 | minus(1.5) }}

Return Data:

TEXT
1.0
-1.0
0.0

modulo(divisor_value)

Returns the numeric remainder of dividing the piped input by the divisor value.

Examples - modulo

EXAMPLE 1

Input:

CODE
{{ 14 | modulo(7) }}
{{ 14 | modulo(4) }}
{{ 14 | modulo(5) }}

Return Data:

TEXT
0
2
4

Explanation: The modulo result is obtained after performing the following four steps:

  1. Divide the dividend (piped input) by the divisor (modulo parameter).

  2. Apply floor to the quotient.

  3. Multiply the divisor by the floored quotient.

  4. Subtract that product from the dividend.

EXAMPLE 2

Input:

CODE
{{ -3 | modulo(2) }}
{{ 3 | modulo(-2) }}

Return Data:

TEXT
1
-1

EXAMPLE 3

Input:

CODE
{{ 2.5 | modulo(2) }}

Return Data:

TEXT
0.5

not_equal(comparison_value)

Returns a Boolean indicating whether the piped input differs from the comparison value.

Examples - not_equal

EXAMPLE 1

Input:

CODE
{{ 1 | not_equal(-2) }}

Return Data:

TEXT
True

EXAMPLE 2

Input:

CODE
{{ 1.0 | not_equal(1) }}

Return Data:

TEXT
False

EXAMPLE 3

Input:

CODE
{{ "3" | not_equal(3) }}

Return Data:

TEXT
False

plus(added_value)

Returns the sum for numeric inputs or a combined sequence for strings, arrays, or objects. For objects with shared keys, values from the added value override those in the piped input.

Examples - plus

EXAMPLE 1

Input:

CODE
{{ 1 | plus(2) }}
{{ 1.5 | plus(-2.5) }}
{{ -3 | plus(2) }}

Return Data:

TEXT
3
-1.0
-1

EXAMPLE 2

Input:

CODE
{{ [1,2,3] | plus([1,2]) }}

Return Data:

TEXT
[
  1,
  2,
  3,
  1,
  2
]

EXAMPLE 3

Input:

CODE
{% set numbers = {"a": 2, "b": 3} %}  
{{ numbers.a | plus(numbers.b) }} 

Return Data:

JSON
5

EXAMPLE 4

Input:

CODE
{{ {"x":1,"y":2} | plus({"y":5,"z":9}) }}

Return Data:

JSON
{
  "x": 1,
  "y": 5,
  "z": 9
}

EXAMPLE 5

Input:

CODE
{{ 'D3' | plus( ' Security' ) }}

Return Data:

JSON
D3 Security

round(decimal_places)

Returns the numeric result of rounding the piped input to the specified number of decimal places. Decimal places are omitted when the rounded value is an integer. Non-integer decimal-place values are treated as 0.

Examples - round

EXAMPLE 1

Input:

CODE
{{ 1.357 | round(0) }}
{{ 1.357 | round(1) }}
{{ 1.357 | round(2) }}

Return Data:

TEXT
1
1.4
1.36

EXAMPLE 2

Input:

CODE
{{ -1.44 | round(0) }}
{{ -1.44 | round(1) }}

Return Data:

TEXT
-1
-1.4

EXAMPLE 3

Input:

CODE
{{ 1 | round(2) }}
{{ 1.0 | round(2) }}
{{ 1.00 | round(2) }}

Return Data:

TEXT
1
1
1

times(multiplier_value)

Returns a result where numeric inputs and numeric strings are multiplied, strings are repeated, and arrays are concatenated.

Examples - times

EXAMPLE 1

Input:

CODE
{{ 3 | times(2) }}
{{ -2 | times(3) }}
{{ 1.5 | times(4) }}

Return Data:

TEXT
6
-6
6.0

EXAMPLE 2

Input:

CODE
{{ 'D' | times(3) }}
{{ '1' | times(3) }}
{{ '-1' | times(3) }}

Return Data:

TEXT
DDD
3
-3

EXAMPLE 3

Input:

CODE
{{ {"k": {"x": {"y": "n", "z": 1 | times(3)}}} }}
{{ {"k": {"x": {"y": "n", "z": "2" | times(3)}}} }}
{{ {"k": {"x": {"y": "n", "z": "D" | times(3)}}} }}

Return Data:

JSON
{'k': {'x': {'y': 'n', 'z': 3}}}
{'k': {'x': {'y': 'n', 'z': 6}}}
{'k': {'x': {'y': 'n', 'z': 'DDD'}}}

EXAMPLE 4

Input:

CODE
{{ [1] | times(2) }}  
{{ ['a'] | times(2) }}
{{ [1,2] | times(2) }}

Return Data:

JSON
[1, 1]
['a', 'a']
[1, 2, 1, 2]

to_float(default)

Returns a floating-point number converted from the piped input. If conversion is not possible, meaning the value is not a plain decimal number or a string that represents one, the filter returns the specified default value. By default, this value is 0.0.

Examples - to_float

EXAMPLE 1

Input:

CODE
{{ 5 | to_float }}  

Return Data:

TEXT
5.0

EXAMPLE 2

Input:

CODE
{% obj = {'x':' 7 '}%}
{{ obj.x | to_float }} 

Return Data:

TEXT
7.0

EXAMPLE 3

Input:

CODE
{{ "" | to_float }}          
{{ "" | to_float(-1) }}     

Return Data:

TEXT
0.0
-1.0

to_int(default, base).

Returns an integer converted from the piped input, with the default value returned when the conversion fails. The base 10 method of interpreting the input is replaced when:

  • a valid base value from 2 through 36 is supplied

  • all characters in the input are valid alphanumeric values for the supplied base

Examples - to_int

EXAMPLE 1

Input:

CODE
{{ -13.3 | to_int }}  

Return Data:

TEXT
-13

EXAMPLE 2

Input:

CODE
{{ 'D' | to_int(3) }}

Return Data:

TEXT
3

EXAMPLE 3

Input:

CODE
{{ '0b1000000' | to_int(0, 2) }}
{{ '0o107'     | to_int(0, 8) }}
{{ '0x4F'      | to_int(0, 16) }}

Return Data:

TEXT
64
71
79

Explanation: The prefixes 0b, 0o, or 0x are supported (optional) syntactic forms used to emphasize that the input values are in binary, octal, or hexadecimal notation, respectively, without altering how the supplied base value controls the conversion.

EXAMPLE 4

Input:

CODE
{{ '1' | to_int(999, 2) }} 
{{ '1' | to_int(999, 3) }}      
{{ 'A' | to_int(999, 35) }}      
{{ 'A' | to_int(999, 36) }}    
{{ 'A' | to_int(999, 37) }}  

Return Data:

TEXT
1
1
10
10
999

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.