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 string format with flexible extraction and formatting options. It supports pretty-printing (indented JSON), compact/minified JSON, extracting a specific field value from the JSON using a path, or formatting the JSON using a user-defined template with placeholders.

This node is useful when you need to transform JSON objects into readable text formats for logging, reporting, notifications, or further text processing. For example:

  • Pretty print JSON for human-readable output.
  • Extract a single value from nested JSON to use in another workflow step.
  • Use a template to generate custom formatted text or HTML snippets based on JSON content.

Properties

Name Meaning
Input JSON The JSON data to convert, provided as a string representation of a JSON object.
Extraction Mode How to extract or format the JSON content. Options:
- Pretty Print: Format JSON with indentation.
- Compact: Minified JSON without whitespace.
- Extract Field: Extract a specific field value using a path.
- Template: Format using a template with {{field}} placeholders.
Field Path (Shown if Extraction Mode is "Extract Field") Dot notation path to the field to extract, e.g., data.items[0].name. Supports array indices.
Template (Shown if Extraction Mode is "Template") A template string with {{field}} placeholders to format JSON values. Example:
<h1>{{title}}</h1>\n<p>{{description}}</p>
Indent Size (Shown if Extraction Mode is "Pretty Print") Number of spaces used for indentation in formatted JSON. Default is 2.
Binary Property Name Name for the output binary property if binary output is enabled (not applicable here).

Output

The node outputs an array of items where each item contains a json property with the conversion result:

  • If Extraction Mode is Pretty Print or Compact, the output json.result is a string containing the formatted JSON.
  • If Extraction Mode is Extract Field, the output json.result contains the extracted field's value (could be any JSON type).
  • If Extraction Mode is Template, the output json.result is the string generated by replacing placeholders in the template with corresponding JSON values.

No binary output is produced for this operation.

Example output JSON structure:

{
  "result": "<formatted string or extracted value>"
}

Dependencies

  • No external services or API keys are required.
  • Uses internal utility functions for JSON formatting and templating.
  • No special environment variables or credentials needed.

Troubleshooting

  • Invalid JSON input: If the Input JSON string is not valid JSON, the node will throw a parsing error. Ensure the JSON is well-formed.
  • Invalid field path: When using "Extract Field" mode, if the specified Field Path does not exist in the JSON, the output may be undefined or cause an error. Verify the path syntax and existence.
  • Template errors: If the template contains placeholders that do not match any fields in the JSON, those placeholders will remain empty or unresolved. Double-check template syntax and field names.
  • Indent size issues: Providing a negative or non-integer Indent Size may cause unexpected formatting results. Use positive integers.

Links and References

Discussion