My question is very simple.

How to export an SVG file from Adobe Illustrator with shape IDs? When I export as SVG my group names turn to groups with group name as ID, that's the behavior I would expect from shapes too, but my shapes just get some random ID instead of their name...

example of desired output:

<g id="liikkeet">
        <polygon id="s281" style="fill:#ED3B95;stroke:#FFFFFF;stroke-width:2;stroke-miterlimit:10;" points="157,515.3 157,408.3     180,385.1 180,369.3 248,369.3 248,391.3 266,391.3 266,402.3 393,402.3 393,513.3   "/>

What am I doing wrong? Currently I get polygons and paths without IDs though I have named them in Illustrator.


4 Answers 4


Feeling your pain. Short answer: AI SVG export is (one of) the reason(s) I need therapy.

Long answer: I've successfully exported SVG from AI (CS6) with id's. See below:

an example of AI layer names

Turns into:

<g id="ZONES">
<path id="Zone3" fill="none" stroke="#000000" stroke-miterlimit="10" d="M756.485,373.758l-1.764,8.361l16.43,3.908l-0.426,2.34
    l-13,69.334l11.33,2.646l1.67-8.312l37.164-186.996L756.485,373.758z M558.887,341.28l92.963,19.719l-0.625,6.619l18.766,3.914
<path id="Zone4" fill="none" stroke="#000000" stroke-miterlimit="10" d="M434.33,427.335c-0.429-1.498-0.982-3.717-1.175-5.787
<polygon id="Zone8" fill="none" stroke="#000000" stroke-miterlimit="10" points="675.512,441.043 661.075,418.389 
    670.225,371.531 651.227,367.615 641.927,414.635 619.298,429.342 551.059,415.363 546.972,433.756 774.876,480.521 778.86,462.17 

A few problems though:

  • sometimes AI just add a random string to that id.. avoid the underscore character, is what I can say with certainty.
  • be prepared that some of these will become paths, and some become polygons, as you see above. So, if you're manipulating them all at once, assign them all a class of "thisIsOneOfMyZones", for example using jQuery. That hack is the best I've come up with so far. Please share if you hack the secret of paths/polygons choice in the export.
  • Possibly, giving the parent group an id will affect how the child node id's are translated in the SVG export. That's needed anyway, or at least convenient if you want to manipulate these programmatically, which I'm guessing you're doing :)

In order to give ID's to groups and paths, you have to give them names in Illustrator. So, if you have a layer called my_layer and a path called my_path in Illustrator and you save them as an svg, you will get:

<g id='my_layer'>
 <path id='my_path' d='...#coordinates...' />

If you don't name your path in Illustrator, it will save it with a random id. If you name the path and the layer with the same name, Illustrator will have to change one of them, as id's must be unique.


Sounds like you are referring to a code sample like this:

<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 18.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
     viewBox="0 0 713 956" enable-background="new 0 0 713 956" xml:space="preserve">
<g id="Layer_1">
    <path fill="#F1F2F2" stroke="#000000" stroke-miterlimit="10" d="M472.5,359.6c-82,0-148.5-66.5-148.5-148.5
<g id="Layer_2">
    <circle fill="#E6E7E8" stroke="#000000" stroke-miterlimit="10" cx="488.3" cy="638.9" r="148.5"/>
<g id="Layer_3">

When you mention "export with shape IDs" to result in <g id="Layer_1"> I would advise placing a shape on each named layer and saving it as SVG. Reference: "I made a map in AI, but the file size is HUGE as an svg?"

You could always export the code and go into a code editor and modify the IDs.


<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px">
        <g id="jjjuho">
            <polygon id="manItsMonday" style="fill:#ED3B95;stroke:#FFFFFF;stroke-width:2;stroke-miterlimit:10;" points="157,515.3 157,408.3180,385.1 180,369.3 248,369.3 248,391.3 266,391.3 266,402.3 393,402.3 393,513.3   "/>


enter image description here


In addition to IDing with the layer name as noted above I have found it's useful to convert my shape/s into compound paths.

This will convert Polygons to Paths which can make things a bit more uniform for your CSS.

In Illustrator: Object> Compound Path> Make

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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