A Singapore Government Agency Website

Convert

The Convert Node allows you to transform structured data into various file formats. The node converts raw data (e.g. JSON string, etc.) into base64-encoded file data suitable for file storage, downloads, or API responses.

Operation Description
Convert JSON String to JSON (Base64) Converts structured data into a pretty-printed JSON file
Convert JSON String to CSV (Base64) Converts an array of objects into a CSV file with optional header row
Convert Text/JSON String to TXT (Base64) Converts text or JSON into a plain text file
Convert Text/JSON String to DOCX (Base64) Converts text or structured data into a Word document with tables

How Does It Work?

Setup Steps:

  1. Build your workflow using Graph Edit Mode (minimum setup: input node → convert node → output node, but you can add more nodes as needed)
  2. Click on the convert node settings to open its configuration
  3. Configure the following data:
    • Select the operation (JSON, CSV, TXT, or DOCX)
    • Enter raw data or use template variables (e.g., {{{ input_data }}}). Refer to each operation’s Input Format section for accepted data types
    • For CSV conversion: Choose whether to include a header row

Output:

The Convert Node returns the converted file data in the following format:

{
  "data": "<<base64-encoded-file-data>>"
}

The data field contains the base64-encoded file data based on the configured conversion operation. This encoded data can be:

  • Uploaded to cloud file transfer
  • Passed to other systems that accept base64 file data

Note: The convert node will always return the variable name as data.

Operations

Convert JSON String to JSON (Base64)

Input Format

  • Input must be a valid JSON string or object

Examples

Example 1 — JSON array:

// Input
[
  {
    "name": "John",
    "age": "25"
  },
  {
    "name": "Jane",
    "age": "30"
  }
]
// Output
{
  "data": "WwogIHsKICAgICJuYW1lIjogIkpvaG4iLAogICAgImFnZSI6ICIyNSIKICB9LAogIHsKICAgICJuYW1lIjogIkphbmUiLAogICAgImFnZSI6ICIzMCIKICB9Cl0="
}

Convert JSON String to CSV (Base64)

Input Format

  • Data must be an array of objects
  • All objects must have the same property keys
  • Values must be simple types (string, number, boolean, null). Nested objects or arrays are not supported
  • Headers are sorted alphabetically in the output

Valid input:

[
  {"name": "John", "age": 25, "city": "New York"},
  {"name": "Jane", "age": 30, "city": "Boston"}
]

Invalid input:

[
  {"name": "John", "details": {"age": 25}}  // ❌ Nested object not allowed
]

Additional setting: Include Header Row — Checked (true) or Unchecked (false)

Examples

Example 1 — Array of objects with header row:

// Input
[
  {
    "header1": "row1-1",
    "header2": "row1-2"
  },
  {
    "header1": "row2-1",
    "header2": "row2-2"
  }
]
// Output
{
  "data": "aGVhZGVyMSxoZWFkZXIyCnJvdzEtMSxyb3cxLTIKcm93Mi0xLHJvdzItMg=="
}

Convert Text/JSON String to TXT (Base64)

Input Format

  • Accepts any input — plain text or JSON string
  • If input is valid JSON, it will be pretty-printed
  • If input is not valid JSON, it is kept as-is (lenient parsing)

Note: The TXT operation never throws an error on invalid JSON. Non-parseable input is treated as literal text.

Examples

Example 1 — Plain text:

// Input
Hello World
// Output
{
  "data": "SGVsbG8gV29ybGQ="
}
// Display in .txt:
Hello World

Example 2 — JSON string:

// Input
{"name":"Alice","age":30}
// Output
{
  "data": "ewogICJuYW1lIjogIkFsaWNlIiwKICAiYWdlIjogMzAKfQ=="
}
// Display in .txt:
{
  "name": "Alice",
  "age": 30
}

Example 3 — Non-JSON text:

// Input
"This is a report summary with {{{ invalid template"
// Output
{
  "data": "VGhpcyBpcyBhIHJlcG9ydCBzdW1tYXJ5IHdpdGgge3t7IGludmFsaWQgdGVtcGxhdGU="
}
// Display in .txt:
This is a report summary with {{{ invalid template

Convert Text/JSON String to DOCX (Base64)

Input Format

  • Accepts plain text, flat objects, arrays of objects (flat), or objects with arrays
  • Nested objects within a top-level object are not supported and will throw an error
  • Array items must only contain simple values (string, number, boolean, null) — nested objects or arrays within items are not supported
  • If input is not valid JSON, it is treated as plain text (lenient parsing)

Note: The DOCX operation never throws an error on invalid JSON. Non-parseable input is treated as literal text.

Invalid input:

{"project": "OMS", "metadata": {"owner": "Team A", "priority": "high"}}  // ❌ Nested object not allowed
[{"name": "John", "address": {"city": "NY"}}]  // ❌ Nested object in array item not allowed
[{"name": "John", "tags": ["a", "b"]}]  // ❌ Nested array in array item not allowed

Examples

Example 1 — Plain text:

// Input
Hello World
// Output
{
  "data": "<base64-encoded .docx binary data>"
}
// Display in .docx:
Hello World

Example 2 — Array of objects:

// Input
[{"name": "Alice", "age": 30}, {"name": "Bob", "age": 25}]
// Output
{
  "data": "<base64-encoded .docx binary data>"
}
// Display in .docx:
┌──────────┬──────────┐
│ name     │ age      │
├──────────┼──────────┤
│ Alice    │ 30       │
│ Bob      │ 25       │
└──────────┴──────────┘

Example 3 — Flat object:

// Input
{"project": "OMS", "version": "1.0"}
// Output
{
  "data": "<base64-encoded .docx binary data>"
}
// Display in .docx:
project: OMS
version: 1.0

Example 4 — Object with arrays:

// Input
{"project": "OMS", "modules": [{"name": "shared", "version": "1.0.0"}, {"name": "frontend", "version": "2.0.0"}]}
// Output
{
  "data": "<base64-encoded .docx binary data>"
}
// Display in .docx:
project: OMS
modules:
┌──────────┬──────────┐
│ name     │ version  │
├──────────┼──────────┤
│ shared   │ 1.0.0    │
│ frontend │ 2.0.0    │
└──────────┴──────────┘

Example 5 — Object with simple array:

// Input
{"name": "Report", "tags": ["urgent", "review", "approved"]}
// Output
{
  "data": "<base64-encoded .docx binary data>"
}
// Display in .docx:
name: Report
tags: urgent, review, approved

When to Use It?

Use Convert Node when:

  • You want to export data in standard formats (JSON, CSV, TXT, DOCX) for downstream processing.
  • You are integrating with systems that require base64-encoded file data.
  • You need to generate plain text reports from workflow data (TXT).
  • You need to generate formatted Word documents with tables from structured data (DOCX).
Chat with me!
Bot Launcher