YAML icon

YAML

Convert data to YAML or from YAML

Overview

This node provides functionality to convert data into YAML format or perform related YAML transformations. Specifically, the "Convert to YAML" operation transforms input JSON data into a YAML file output. This is useful when you need to generate YAML files from structured data for configuration, deployment scripts, or other automation tasks that require YAML input.

Common scenarios include:

  • Exporting JSON data from previous nodes into a YAML file for use in infrastructure-as-code tools.
  • Generating configuration files dynamically in YAML format.
  • Preparing data for systems that consume YAML rather than JSON.

For example, you might take an array of JSON objects representing server configurations and convert them into a single YAML file or multiple YAML files, depending on your needs.

Properties

Name Meaning
Mode Choose whether to convert all input items into one single YAML file ("All Items to One File") or convert each item into a separate YAML file ("Each Item to Separate File").
Put Output File in Field The name of the binary field where the resulting YAML file(s) will be stored. For example, "data".
Options: Add Byte Order Mark (BOM) Whether to add a special marker at the start of the text file to help some programs correctly interpret the file encoding. Only applicable for certain encodings like UTF-8.
Options: Format Whether to format the JSON data before conversion for easier reading.
Options: Encoding Character set encoding to use for the output YAML file. Many options are available, such as utf8, ascii, base64, etc. Default is utf8.
Options: File Name The desired name of the output YAML file, e.g., "myFile.yaml". If not specified, a default name may be used.

Output

The node outputs binary data containing the generated YAML file(s). The binary data is placed in the field specified by the "Put Output File in Field" property (default "data"). The output can be either:

  • A single YAML file combining all input items (if mode is "once").
  • Multiple YAML files, one per input item (if mode is "each").

The binary data represents the YAML content encoded with the selected character encoding and optionally includes a BOM marker.

Dependencies

  • No external API keys or services are required.
  • The node relies on internal libraries to perform JSON-to-YAML conversion and encoding.
  • No special environment variables or n8n credentials are needed.

Troubleshooting

  • Issue: Output file is empty or malformed YAML.

    • Cause: Input data may not be valid JSON or may contain unsupported types.
    • Solution: Verify input data correctness and structure before conversion.
  • Issue: Encoding problems or unreadable characters in output file.

    • Cause: Incorrect encoding selected or missing BOM when required.
    • Solution: Adjust the encoding option or enable the BOM option if using UTF-8.
  • Issue: File name not respected or missing.

    • Cause: File name property left empty or invalid.
    • Solution: Provide a valid file name in the options to ensure proper naming.

Links and References

Discussion