# Data, objects and encoding

Source: https://govform.com/resources/documentation/article/34-03-liquid-data-objects-and-encoding-filters
Topic: Liquid Templates

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 Govform both expose `base64_encode` and `base64_decode`. Govform 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 Govform 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` |

## Govform filters

These filters are added by Govform 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

-   [Write Liquid templates](<https://govform.com/resources/documentation/article/11-write-liquid-templates>)
-   [Use Markdown and HTML](<https://govform.com/resources/documentation/article/12-use-markdown-and-html>)

## 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 action bodies can include up to **25 MiB of combined raw files** as Base64, including repeated references; encoding adds approximately one third before JSON overhead. For larger files, use **Upload files** to stream to Govform storage or your SharePoint, S3, Google Cloud Storage or Azure Blob Storage, or use authenticated ordinary-file/Bulk Data download APIs. The 20 GB upload ceiling and any lower component/security limits are separate from this Base64 allowance. Submitted revision selection requires retained Response history.

[Bulk Data files, submitted revisions and integration examples](<https://govform.com/resources/documentation/article/33-14-api-bulk-data-files>)

[Stream ordinary uploaded files](<https://govform.com/resources/documentation/article/33-07-api-list-download-uploaded-files>) · [Upload and processing limits](<https://govform.com/resources/documentation/article/23-09-component-file>)
