- 2 minutes to read

Formula - removebom

The removebom Formula function returns the content without a leading byte order mark (BOM).

Syntax

removebom(content)

Parameters

Parameter Required Description
content Yes The text to clean: body, context, or the result of another function.

Returns

The content with a leading BOM removed from each value. Content without a BOM is returned unchanged.

Examples

A UTF-8 BOM is the bytes EF BB BF at the start of a file or message (see With BOM vs without BOM). It's invisible in most editors, but it is still a character, and it can sit at the start of base64 text that you decode with base64decode.

Example 1: Remove the BOM from decoded base64 content

Input

The Log API takes the message body base64-encoded. To log a body that is itself the base64 text 77u/dGVzdCDDpcOkw7bDhcOEw5Y=, you send it encoded once more:

Nzd1L2RHVnpkQ0REcGNPa3c3YkRoY09FdzVZPQ==

The logged body, shown on the Message Body tab and read as UTF-8, is:

77u/dGVzdCDDpcOkw7bDhcOEw5Y=

base64decode(body) turns this into the bytes EF BB BF (a UTF-8 BOM) followed by test åäöÅÄÖ. The BOM stays in the result as an invisible first character.

Formula and Result

Compare the length of the decoded text with and without removebom, using length:

Formula Result Screenshot
length(base64decode(body)) 12 Test Expression tab: length(base64decode(body)) returns 12 for the decoded text with a BOM
length(removebom(base64decode(body))) 11 Test Expression tab: length(removebom(base64decode(body))) returns 11 once the BOM is removed

test åäöÅÄÖ is 11 characters; the extra character in the first result is the BOM, which removebom strips.

The same applies to any content that holds base64 text starting with a BOM, for example a JSON property value read with jsonPath: removebom(base64decode(jsonPath('Payload', body))).

Notes

  • Only a BOM at the start of each value is removed. To change characters elsewhere in the text, use replace or replaceregex.
  • A message body read with a without BOM Character Encoding, such as UTF-8 (without BOM), already has its BOM removed before the formula runs; removebom matters for BOMs inside decoded or embedded content.

Next Steps