Fork me on GitHub

Flamingo SVG Transcoder

Transform SVG images into pure Java2D icons for your Swing applications

This tool let you transform SVG images into pure Java2D code with no external dependencies. The following features are supported:

These SVG features are not supported:

The SVG transcoder successfully converted more than 5000 icons from various GNOME and KDE themes. On average the generated .class file with gzip compression is about 30% bigger than the corresponding svgz image. With pack200+gzip compression it's about 40% smaller.


The transcoder is available as a simple graphical interface, just drop your SVG images on the window and a Java source file will be generated in the directory of the original image.


Flamingo SVG Transcoder GUI

Ant Task

You can also transform several SVG images with an Ant task. The syntax is similar to the copy task:

<taskdef name="svg2java"
<svg2java todir="build/icons" verbose="true" namingStrategy="default" template="plain">
  <fileset dir="src/main/resources/svg" includes="**/*.svg*"/>
Attribute Description Required
file The SVG file to transform. Yes, unless a nested resource collection element is used.
todir The directory to transform to. Yes
namingStrategy The naming strategy used to generate the Java class names from the SVG file names:
  • "default" tries to keep the original file name and tweaks it to make it a legal Java class name (i.e. edit-copy.svg will turn into
  • "camelcase" generates a camel cased class name from the SVG file name (i.e. edit-copy.svg will turn into
No; defaults to "default".
template The template used to generate the Java class:
  • "plain": generates a simple class with a static paint() method.
  • "icon": generates an implementation of javax.swing.Icon.
  • "resizable": generates a ResizableIcon as defined by the Flamingo API.
No; defaults to "plain".
overwrite Overwrite existing files even if the destination files are newer. No; defaults to false.
flatten Ignore the directory structure of the source files, and transform all files into the directory specified by the todir attribute. No; defaults to false.
verbose Log the files that are being transformed. No; defaults to false.

The Ant task is available for download here.


BSD, Apache License 2.0


The SVG Transcoder has been originaly developped by Kirill Grouchnikov as part of the Flamingo project (see his blog for more information). It leverages the Apache Batik project for parsing the SVG files.


Emmanuel Bourg (, @smanux)


You can download this project in either zip or tar formats.

You can also clone the project with Git by running:

$ git clone git://