Data Converter icon

Data Converter

Convert between various data formats - Base64, Binary, JSON, XML, YAML, CSV, HTML, and more

Overview

The node converts JSON data into a Base64-encoded string. This operation is useful when you need to encode structured JSON data into a compact, text-based format that can be easily transmitted or stored in systems that only support text content. For example, encoding JSON as Base64 is helpful for embedding JSON payloads in URLs, HTTP headers, or other text-only fields.

Practical examples:

  • Encoding configuration objects to Base64 for safe transmission over protocols that do not support raw JSON.
  • Preparing JSON data for storage in databases or files that expect Base64 strings.
  • Sending JSON data through messaging systems that require Base64 encoding.

Properties

Name Meaning
Input JSON The JSON data to convert. Must be a valid JSON string (e.g., {"key": "value"}).
Binary Property Name (Optional) Name for the output binary property if outputting the result as binary data.

Output

The node outputs a JSON object with a single field containing the Base64-encoded string representation of the input JSON.

  • If the option to output as binary is not selected, the output JSON will have a field (usually result) holding the Base64 string.
  • If the option to output as binary is selected, the output will contain a binary property with the Base64 data prepared as binary content, suitable for further binary processing in n8n workflows.

Example JSON output (when not outputting binary):

{
  "result": "eyJrZXkiOiAidmFsdWUifQ=="
}

This string is the Base64 encoding of {"key": "value"}.

Dependencies

  • No external services are required.
  • The node uses internal utility functions for Base64 encoding.
  • No special credentials or environment variables are needed.

Troubleshooting

  • Invalid JSON input: If the input JSON string is malformed, the node will throw an error. Ensure the JSON is correctly formatted.
  • Empty input: Providing empty or missing JSON input may result in encoding an empty object {} or errors depending on the input.
  • Binary output issues: When enabling binary output, ensure the specified binary property name does not conflict with existing properties and is handled properly downstream.
  • Encoding errors: Rarely, if the JSON contains unsupported characters or structures, encoding might fail. Validate JSON before conversion.

Links and References

Discussion