Skip to main content

Base64Decode@1

Node Base64Decode@1 converts Base64 encoded strings back to their original string values. It decodes Base64 strings using UTF-8 encoding and is essential for processing encoded data from APIs, configuration files, or secure storage.

Adapter Prerequisites

  • General availability: All adapters support this node type.

Node Configuration

For fields path, targetPath, targetValueWriteMode, and targetValueKind, see Overview.

transformations:
- type: Base64Decode@1
path: $.users[*] # Path to objects containing encoded data
sourcePath: $.encodedPassword # Path to Base64 encoded value
targetPath: $.password # Path where decoded value will be stored

Parameters

Required Parameters

ParameterTypeDescription
pathstringJSONPath to objects containing the Base64 encoded data
sourcePathstringRelative path to the Base64 encoded value within each object
targetPathstringRelative path where the decoded value will be stored

Decoding Process

The node performs Base64 decoding through these steps:

  1. Object Selection: Uses path to select objects containing encoded data
  2. Value Retrieval: Extracts the Base64 encoded string from sourcePath
  3. Base64 Decoding: Converts the Base64 string to a byte array
  4. UTF-8 Conversion: Converts the byte array back to a UTF-8 string
  5. Result Storage: Stores the decoded string at targetPath

Null Value Handling

  • Null Preservation: Null values are preserved without decoding
  • Empty Strings: Empty strings are decoded (result in empty decoded string)
  • Invalid Base64: Invalid Base64 strings throw a FormatException

Examples

Example 1: Decode User Credentials

Decode Base64 encoded passwords:

transformations:
- type: Base64Decode@1
path: $.users[*]
sourcePath: $.encodedPassword
targetPath: $.password

Input:

{
"users": [
{ "id": "user1", "encodedPassword": "cGFzc3dvcmQxMjM=" },
{ "id": "user2", "encodedPassword": "bXlTZWNyZXQ0NTY=" }
]
}

Output:

{
"users": [
{ "id": "user1", "encodedPassword": "cGFzc3dvcmQxMjM=", "password": "password123" },
{ "id": "user2", "encodedPassword": "bXlTZWNyZXQ0NTY=", "password": "mySecret456" }
]
}

Example 2: Decode API Keys

Extract original API keys from encoded format:

transformations:
- type: Base64Decode@1
path: $.services[*]
sourcePath: $.encodedApiKey
targetPath: $.apiKey

Input:

{
"services": [
{ "name": "API1", "encodedApiKey": "c2VjcmV0LWtleS0xMjM=" },
{ "name": "API2", "encodedApiKey": "YW5vdGhlci1zZWNyZXQ=" }
]
}

Output:

{
"services": [
{ "name": "API1", "encodedApiKey": "c2VjcmV0LWtleS0xMjM=", "apiKey": "secret-key-123" },
{ "name": "API2", "encodedApiKey": "YW5vdGhlci1zZWNyZXQ=", "apiKey": "another-secret" }
]
}

Example 3: Decode Configuration Values

Decode configuration parameters from secure storage:

transformations:
- type: Base64Decode@1
path: $.configuration.secure[*]
sourcePath: $.encodedValue
targetPath: $.value

Input:

{
"configuration": {
"secure": [
{ "key": "db_password", "encodedValue": "ZGF0YWJhc2VfcGFzcw==" },
{ "key": "api_token", "encodedValue": "dG9rZW5fMTIzNDU2" }
]
}
}

Output:

{
"configuration": {
"secure": [
{ "key": "db_password", "encodedValue": "ZGF0YWJhc2VfcGFzcw==", "value": "database_pass" },
{ "key": "api_token", "encodedValue": "dG9rZW5fMTIzNDU2", "value": "token_123456" }
]
}
}

Example 4: Decode Data URI Content

Extract content from data URIs:

transformations:
- type: Base64Decode@1
path: $.files[*]
sourcePath: $.base64Content
targetPath: $.textContent

Input:

{
"files": [
{ "name": "readme.txt", "base64Content": "SGVsbG8gV29ybGQh" },
{ "name": "config.json", "base64Content": "eyJzZXR0aW5nIjogInZhbHVlIn0=" }
]
}

Output:

{
"files": [
{ "name": "readme.txt", "base64Content": "SGVsbG8gV29ybGQh", "textContent": "Hello World!" },
{ "name": "config.json", "base64Content": "eyJzZXR0aW5nIjogInZhbHVlIn0=", "textContent": "{\"setting\": \"value\"}" }
]
}

Example 5: Handle Null Values

Demonstrate null value handling:

transformations:
- type: Base64Decode@1
path: $.items[*]
sourcePath: $.encodedData
targetPath: $.data

Input:

{
"items": [
{ "id": 1, "encodedData": "aGVsbG8=" },
{ "id": 2, "encodedData": null },
{ "id": 3, "encodedData": "d29ybGQ=" }
]
}

Output:

{
"items": [
{ "id": 1, "encodedData": "aGVsbG8=", "data": "hello" },
{ "id": 2, "encodedData": null, "data": null },
{ "id": 3, "encodedData": "d29ybGQ=", "data": "world" }
]
}

Example 6: Decode Multiple Fields

Decode multiple Base64 fields in the same object:

transformations:
- type: Base64Decode@1
path: $.credentials[*]
sourcePath: $.encodedUsername
targetPath: $.username
- type: Base64Decode@1
path: $.credentials[*]
sourcePath: $.encodedPassword
targetPath: $.password

Input:

{
"credentials": [
{
"service": "database",
"encodedUsername": "YWRtaW4=",
"encodedPassword": "cGFzc3dvcmQ="
}
]
}

Output:

{
"credentials": [
{
"service": "database",
"encodedUsername": "YWRtaW4=",
"encodedPassword": "cGFzc3dvcmQ=",
"username": "admin",
"password": "password"
}
]
}

Use Cases

  • Credential Decoding: Decode encoded passwords, API keys, or tokens from configuration
  • Data Processing: Extract original content from Base64 encoded API responses
  • File Content Extraction: Decode file contents received in Base64 format
  • Configuration Management: Retrieve original values from obfuscated configuration data
  • Data URI Processing: Extract content from data URIs for further processing
  • Secure Storage: Decode values retrieved from secure storage systems
  • API Integration: Process Base64 encoded data from external APIs

Error Handling

The node will throw errors when:

  • The input data context is null
  • A Base64 string contains invalid characters (FormatException)
  • JSONPath expressions are invalid

Behavior Notes

  • UTF-8 Encoding: All decoded strings use UTF-8 character encoding
  • Null Safety: Null values are preserved without causing errors
  • String Conversion: Values are converted to strings before decoding
  • Error Logging: Invalid Base64 strings are logged with path information
  • Memory Efficient: Processing is done per object, not loading all data at once

Security Considerations

  • Not Encryption: Base64 is encoding, not encryption - it provides no security
  • Sensitive Data: Be cautious when logging decoded values containing sensitive information
  • Validation: Consider validating decoded values for expected formats or patterns