svg-converter

n8n community node to convert SVG input into PNG binary data or Base64-encoded PNG.

Package Information

Downloads: 5 weekly / 154 monthly
Latest Version: 0.1.1
Author: jtanguay

Documentation

n8n-nodes-svg-converter

This is an n8n community node. It converts SVG input into either:

  • a PNG binary file,
  • a Base64-encoded PNG string,
  • or both at once.

It supports SVG input from:

  • a direct text field,
  • a JSON field from the incoming item,
  • or a binary property containing an SVG file.

Installation

In your self-hosted n8n instance, install from npm:

npm install n8n-nodes-svg-converter

Or install it from the Community Nodes UI in n8n.

Operations

Convert SVG

Input sources:

  • SVG text
  • JSON field
  • Binary property

Output modes:

  • PNG Binary
  • Base64
  • Both

Parameters

  • Source: Where the SVG comes from.
  • SVG: Raw SVG markup when using direct input.
  • JSON Field Name: Field containing the SVG markup.
  • Input Binary Property: Binary field containing the SVG file.
  • Output: PNG Binary, Base64, or Both.
  • PNG Binary Property: Binary property name for the rendered PNG.
  • Base64 Field Name: JSON field name for the Base64 string.
  • File Name: Optional output PNG file name.
  • Width / Height: Optional raster size.
  • Density: SVG render density used by sharp.
  • Background Color: Optional flatten background. Leave empty for transparency.

Example

Direct SVG text to PNG

  1. Add the SVG Converter node.
  2. Set Source to SVG Text.
  3. Paste SVG markup into SVG.
  4. Set Output to PNG Binary.
  5. Run the node.

JSON field to Base64

If an incoming item contains:

{
  "svg": "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"120\" height=\"40\"><text x=\"10\" y=\"25\">Hello</text></svg>"
}

then set:

  • SourceJSON Field
  • JSON Field Namesvg
  • OutputBase64

The node will write the Base64 PNG string to the configured field.

Development

npm install
npm run dev

License

MIT

Discussion