Convert JSON Objects to Base64 Strings with File Processing
Last edited 58 days ago
Encode JSON to Base64 String in n8n
This example workflow demonstrates how to convert a JSON object into a base64-encoded string using n8n’s built-in file processing capabilities. This is a common requirement when working with APIs, webhooks, or SaaS integrations that expect payloads to be base64-encoded.
Tip: The three green-highlighted nodes (Stringify → Convert to File → Extract from File) can be wrapped in a Subworkflow to create a reusable Base64 encoder in your own projects.
🔧 Requirements
- Any running n8n instance (local or cloud)
- No credentials or external services required
What This Workflow Does
- Generates example JSON data
- Converts the JSON to a string
- Saves the string as a binary file
- Extracts the file’s contents as a base64 string
- Outputs the base64 string on the final node
Step-by-Step Setup
-
Manual Trigger
Start the workflow using theManual Executionnode. This is useful for testing and development. -
Create JSON Data
TheCreate Json Datanode uses raw mode to construct a sample object with all major JSON types: strings, numbers, booleans, nulls, arrays, nested objects, etc. -
Convert to String
TheConvert to Stringnode uses the expression={{ JSON.stringify($json) }}to flatten the object into a single string field namedjson_text. -
Convert to File
TheConvert to Filenode takes thejson_textvalue and saves it to a UTF-8 encoded binary file in the propertyencoded_text. -
Extract from File
This node takes the binary file and extracts its contents as a base64-encoded string. The result is saved in thebase64_textfield.
Customization Tips
- Replace the sample JSON in the
Create Json Datanode with your own payload structure. - To make this reusable, extract the three core nodes into a Subworkflow or wrap them in a custom Function.
- Use the
base64_textoutput field to post to APIs, store in databases, or include in webhook responses.
You may also like
New to n8n?
Need help building new n8n workflows? Process automation for you or your company will save you time and money, and it's completely free!





