Data Converter icon

Data Converter

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

Overview

The node provides a versatile "Data Converter" tool that supports various data format transformations, including Base64 encoding/decoding, binary conversions, text encodings, and string manipulations. Specifically, for the String resource with the Pad Text operation, it adds padding characters to a given text input to reach a specified length. This is useful when you need to format strings to a fixed width, for example, aligning text output in reports or preparing data for systems requiring fixed-length fields.

Practical examples:

  • Padding a username with spaces on the right to ensure all usernames have 15 characters.
  • Adding zeros on the left of a number string to create uniform numeric codes.
  • Center-aligning text by padding both sides with a specific character.

Properties

Name Meaning
Input Data The text string to be padded.
Pad Character The character used for padding (default is space " ").
Pad Length The target total length of the string after padding (default is 10).
Pad Side Which side(s) to add padding: Left, Right, or Both sides.

Note: These properties are part of the "stringOperations" collection when applying multiple operations or directly as parameters for the "padText" operation.

Output

The node outputs a JSON object with a result field containing the padded string.

Example output JSON structure:

{
  "result": "   paddedText"
}

If the operation produces an object (e.g., parsing email address), those fields are merged into the output JSON alongside result. For the pad text operation, the output is simply the padded string under result.

No binary output is produced by this operation.

Dependencies

  • No external services or API keys are required.
  • The node relies on internal utility functions for string manipulation.
  • No special environment variables or n8n configurations are needed.

Troubleshooting

  • Common issues:

    • If the pad length is less than or equal to the input string length, no padding will be added; the original string is returned.
    • Using multi-character strings as the pad character may not behave as expected since only the first character is typically used.
    • Providing empty input data will result in a string consisting solely of padding characters.
  • Error messages:

    • Errors related to invalid parameter types (e.g., non-string input) may occur if inputs are not properly validated before execution.
    • If the node fails, enabling "Continue On Fail" allows processing subsequent items without interruption.

Links and References

Discussion