Skip to main content
Version: 1.4.0

Humanize

Text Processing Data Analysis

Synopsis

Converts numbers to human-readable format with metric prefixes.

Schema

- humanize:
field: <ident>
target_field: <string>
format: <string>
precision: <integer>
binary: <boolean>
suffix: <string>
description: <text>
if: <script>
ignore_failure: <boolean>
ignore_missing: <boolean>
on_failure: <processor[]>
on_success: <processor[]>
tag: <string>

Configuration

The following fields are used to define the processor:

FieldRequiredDefaultDescription
fieldY-Source field containing numeric value to humanize
target_fieldNSame as fieldTarget field to store humanized result
formatNsizeFormat type: size, number, time, frequency
precisionN1Decimal places to show in result
binaryNfalseUse binary (1024) instead of decimal (1000) base
suffixN-Custom suffix to append to result
descriptionN-Explanatory note
ifN-Condition to run
ignore_failureNfalseContinue processing if conversion fails
ignore_missingNfalseSkip processing if referenced field doesn't exist
on_failureN-See Handling Failures
on_successN-See Handling Success
tagN-Identifier

Details

Converts numeric values to human-readable format using appropriate metric prefixes (K, M, G, T) or time units. The processor makes large numbers more readable by automatically selecting the appropriate scale and unit.

The processor supports different format types including data sizes, general numbers, time durations, and frequencies, each with appropriate unit conventions.

note

The processor automatically selects the most appropriate unit based on the magnitude of the input number. For example, 1500000 becomes "1.5M" and 2048 becomes "2.0K" (or "2.0Ki" in binary mode).

When binary is enabled, the processor uses 1024-based calculations (Ki, Mi, Gi, Ti) instead of 1000-based (K, M, G, T), which is common for memory and storage sizes.

warning

Non-numeric input values will cause the processor to fail unless ignore_failure is set to true. Ensure the source field contains valid numeric data.

Examples

Basic Number Humanization

Converting large number to readable format...

{
"byte_count": 1048576
}
- humanize:
field: byte_count
target_field: readable_size

creates human-readable size:

{
"byte_count": 1048576,
"readable_size": "1.0MB"
}

Binary Format

Using binary (1024-based) formatting...

{
"memory_bytes": 2147483648
}
- humanize:
field: memory_bytes
binary: true
precision: 2
target_field: memory_size

formats with binary units:

{
"memory_bytes": 2147483648,
"memory_size": "2.00GiB"
}

Time Format

Humanizing time duration in milliseconds...

{
"duration_ms": 125000
}
- humanize:
field: duration_ms
format: time
target_field: duration_human

converts to time units:

{
"duration_ms": 125000,
"duration_human": "2m 5s"
}

Custom Precision

Setting specific decimal precision...

{
"request_count": 1234567
}
- humanize:
field: request_count
format: number
precision: 3
target_field: formatted_count

formats with 3 decimal places:

{
"request_count": 1234567,
"formatted_count": "1.235M"
}

With Custom Suffix

Adding custom suffix to humanized value...

{
"frequency_hz": 2500000
}
- humanize:
field: frequency_hz
format: frequency
suffix: "Hz"
target_field: readable_frequency

includes custom suffix:

{
"frequency_hz": 2500000,
"readable_frequency": "2.5MHz"
}