In the document I found that SVG files can be exported, but there is no information of Import. How can I do that?

  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour and check the faqs! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, [by clicking the checkmark sign](tinyurl.com/4srwe26 $\endgroup$ – Dunlop Jan 7 '20 at 5:37
  • 3
    $\begingroup$ If you look at the documentation (I am using MMA 12) SVG is not listed as a format that can be imported. You can check which file formats are supported by using the command $ImportFormats $\endgroup$ – Dunlop Jan 7 '20 at 5:38
  • 1
    $\begingroup$ @Dunlop Thank you for your advice. I just want to know how can I do it, it's not limited to be done with Import. I didn't found any related information on this forum, so I think maybe I have to use some external programs to do this. Or I may need to learn something about svg and do it by myself. $\endgroup$ – bcegkmqs23 Jan 7 '20 at 7:50

This is not currently supported by the built-in functions, but there is a function called SVGImport in the function repository that can do this: https://resources.wolframcloud.com/FunctionRepository/resources/SVGImport

  • $\begingroup$ Thank you. I've forgotten this site. I knew this website just yesterday. $\endgroup$ – bcegkmqs23 Jan 7 '20 at 8:12

Alternative answer: Use the SVG importer from my Prototypes paclet:


To install the paclet, run this command:


Note that this paclet has many many functions, but you may be able to extract just the SVG importer if that's all you need.

After that you can load the package:


Normally this package autoloads when you use a function from the package, but not in this case which uses Import.

Next run Import to import the SVG file (example source):

Import["D:\\tmp\\in.svg", "SVG"]

enter image description here

Important note: This implementation uses the Apache-Batik java library and imports the SVG as a raster image and not as a graphics object. So you lose the scalability of the SVG. On the other hand, this implementation does a very faithful rendering of SVG file (exceeding, in certain cases, the result from the SVGImport resource function (which works well in a lot of cases too).


Depending on your usage scenario, converting the SVG files to PDF via Inkscape and then importing the PDF files using the regular Mathematica Import[] function might be a viable alternative.

I tried this with Inkscape 0.92 and Mathematica 12 on Linux, albeit only for one file.

Inkscape can also do the conversion from SVG to PDF using command line options. Therefore, if you have many files, you could automatize the conversion process.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.