Data, objects and encoding
Use these filters to serialize and parse data, inspect values, read variables and prepare safe payloads. Treat action responses and incoming data as untrusted, and encode for the destination rather than applying HTML escaping by habit.
Base64 compatibility: LiquidJS and Govforms both expose base64_encode and base64_decode. Govforms supplies compatible implementations in the running service, so the same Liquid syntax is used.
Standard Liquid filters
These filters are provided as standard by the Liquid language. They are available anywhere Govforms accepts a Liquid template.
| Filter | What it does | Example |
|---|---|---|
base64_decode() | Decodes base64 text Converts a base64-encoded string back to UTF-8 text. | {{ "SGVsbG8=" | base64_decode }} → Hello |
base64_encode() | Encodes text as base64 Converts text or binary data to a base64-encoded string. | {{ "Hello" | base64_encode }} → SGVsbG8= |
default(fallback) | Provides fallback for empty values Returns fallback if input is null, undefined, or empty string. | {{ empty_var | default: "N/A" }} → N/A |
hmac_sha256(secret_key) | Creates an HMAC-SHA256 signature Signs the input using the supplied secret key and returns a hexadecimal digest. | {{ message | hmac_sha256: secret_key }} |
inspect(spaces) | Converts a value to readable JSON Serializes a value as JSON, with optional indentation for inspection. | {{ form | inspect: 2 }} |
json() | Converts value to JSON string Serializes value as JSON. | {{ my_object | json }} → {"key":"value"} |
jsonify(spaces) | Converts a value to JSON Serializes a value as JSON, with optional indentation. | {{ form | jsonify }} |
raw() | Outputs a value without escaping Marks the value as raw output. Only use this with content that is safe to render. | {{ trusted_html | raw }} |
sha256() | Creates a SHA-256 digest Hashes the input and returns its hexadecimal SHA-256 digest. | {{ message | sha256 }} |
to_integer() | Converts a value to an integer Parses the input as a base-10 whole number. | {{ "42" | to_integer }} → 42 |
Govforms filters
These filters are added by Govforms for service-building and data-handling tasks.
| Filter | What it does | Example |
|---|---|---|
base64_decode(string) | Decodes base64 string Converts base64 encoded string back to UTF-8 text. | {{ "aGVsbG8=" | base64_decode }} → hello |
base64_encode(string) | Encodes string as base64 Converts string to base64 encoding using Buffer. | {{ "hello" | base64_encode }} → aGVsbG8= |
form_to_json(form) | Converts form data to JSON object Extracts all field values into clean JSON structure. | {{ form | form_to_json }} |
get_var(variable_name) | Gets variable value by name from context Dynamically retrieves a variable value using its name as a string. | {{ "ke1individStratObj_3" | get_var }} |
jsonstr(string) | Escapes string for JSON without outer quotes Like to_json_string but removes the surrounding quotes. | {{ "hello
world" | jsonstr }} → hello\nworld |
odata_string_escape(string) | Escapes string for OData queries Escapes single quotes for use in OData query strings. | {{ "O'Reilly" | odata_string_escape }} → O''Reilly |
parse_json(json_string) | Parses JSON string into object Converts JSON string back into JavaScript object. | {{ '{"key": "value"}' | parse_json }} |
remove_data_url_properties(object) | Removes properties containing data URLs from objects Recursively removes properties that contain base64 data URLs. | {{ form_data | remove_data_url_properties }} |
to_json_string(value) | Converts value to JSON string format Properly escapes value for use in JSON, including quotes. | {{ my_value | to_json_string }} |
uuid() | Generates unique identifier Creates a new UUID string. | {{ "" | uuid }} → generates random UUID |
xpath(xml_string, xpath_expression, single) | Extracts data from XML using XPath expressions Parses XML and applies XPath query. Set single to "single" for single result. | {{ xml_data | xpath: "//item/@id" }} |
Related guidance
Bulk Data evidence and integrations
The validated CSV includes respondent corrections; the untouched upload is retained separately. Use Upload files to send a selected Bulk Data evidence version to a configured file store. API actions can send up to 25 MiB of combined raw files as Base64; larger files can be streamed through the Bulk Data download API. Submitted revision selection requires retained Response history.
Bulk Data files, submitted revisions and integration examples
