Convert JSON Objects to Base64 Strings with File Processing
## 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 1. Generates example JSON data 2. Converts the JSON to a string 3. Saves the string as a binary file 4. Extracts the file's contents as a base64 string 5. Outputs the base64 string on the final node --- ## Step-by-Step Setup 1. **Manual Trigger** Start the workflow using the `Manual Execution` node. This is useful for testing and development. 2. **Create JSON Data** The `Create Json Data` node uses raw mode to construct a sample object with all major JSON types: strings, numbers, booleans, nulls, arrays, nested objects, etc. 3. **Convert to String** The `Convert to String` node uses the expression `={{ JSON.stringify($json) }}` to flatten the object into a single string field named `json_text`. 4. **Convert to File** The `Convert to File` node takes the `json_text` value and saves it to a UTF-8 encoded binary file in the property `encoded_text`. 5. **Extract from File** This node takes the binary file and extracts its contents as a base64-encoded string. The result is saved in the `base64_text` field. --- ## Customization Tips - Replace the sample JSON in the `Create Json Data` node 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_text` output field to post to APIs, store in databases, or include in webhook responses.
New buyers can create an account from the cart to unlock a controlled $10 first-purchase credit on eligible orders of $25+.
Secure checkout powered by Stripe
Support
How to import this workflow into n8n
- 1Purchase or download the workflow to get the n8n workflow JSON file.
- 2In your n8n instance, open Workflows and choose "Import from File" (or paste the JSON with Ctrl+V on the canvas).
- 3Open each node marked with a credential warning and connect your own accounts and API keys.
- 4Run the workflow once manually to verify the data flow, then toggle it to Active.
Related File & Document Management workflows
- Automate Invoice Data Extraction to Airtable with OCR and AI$14.99
- Automate PDF Invoice Creation from Google Sheets Using PDF.co$4.99
- Create Custom PDF Documents from Templates with Gemini & Google Drive$24.99
- Automatically Save and Organize Outlook Email Attachments in OneDrive Folders$9.99
- Automate Invoice Data Extraction from Google Drive to Google Sheets with Mistral OCR$14.99
- Convert Files to Markdown with Datalab.to API in n8n$9.99
More from Wyeth
Need this deployed? We'll set it up for you.
Our automation experts deploy this workflow in your stack, connect your accounts, and verify it works — or build a custom solution from scratch.