Articles in this section

bytes helper

The bytes helper converts a numeric byte value into a human-readable size string (e.g. 825399 → 825.4 kB). Use it to display file sizes or data volumes in a readable format. Units follow SI (base-1000) conventions: kB, MB, GB, TB.

Syntax

{{bytes input precision}}

input -- The byte value to convert. Required. Accepts a number or numeric string. If the input is a non-numeric string, the helper returns the byte length of the string instead.

precision -- The number of decimal places in the output. Optional. Defaults to 2. Set to 0 for whole-number output.

Examples

Convert byte values to readable sizes

{{bytes record.a}}
{{bytes record.b}}
{{bytes record.c}}
{{bytes record.d}}

Input:

{
 "record": {
 "a": "foo",
 "b": 13661855,
 "c": 825399,
 "d": 1396
 }
}

Output:

3 B
13.66 MB
825.4 kB
1.4 kB

record.a is the string "foo" (3 characters), so the helper returns its byte length (3 B) rather than treating it as a numeric value.

Control decimal precision

{{bytes record.b 0}}
{{bytes record.b 3}}

Input:

{ "record": { "b": 13661855 } }

Output:

14 MB
13.662 MB

Usage notes

  • bytes uses SI (base-1000) units, not binary (base-1024). For example, 1024 returns 1.02 kB, not 1 KB.
  • If the input is a non-numeric string, the helper returns the byte length of that string -- not an error.
  • Set precision to 0 for whole-number output, or a higher value for more decimal places.
  • Use triple braces ({{{ }}}) if you need the raw output string without Celigo's automatic formatting.