Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am working on a process in which we will generate SVG's with id's on certain elements. I want to be able to edit the SVG in Adobe Illustrator. However, I found that when I edit the file in Illustrator, the id's are all changed.

Can Illustrator be made to keep my id's?

share|improve this question

migrated from Dec 21 '12 at 3:15

This question came from our site for professional and enthusiast programmers.

could you share a sample generated svg ? – George Profenza Dec 21 '12 at 0:22
up vote 3 down vote accepted

I've been trying to use Illustrator with svg for a few years now, with mixed success. It usually preserves the IDs, if you save in in the most permissive format (SVG 1.1); but it really loves to rewrite the various svg elements into it's own way of thinking about them. I strongly recommend not using Illustrator to edit svg files that you want to have clean and careful markup in. You might use Inkscape instead.

share|improve this answer

So I know this question was asked a long time ago. Since Inkscape is pretty slow through x11 on Mac, I decided to post my solution here in case it helps someone else.

If you have python installed on your mac, you can use this script to modify the svg before you open it in illustrator. Then after you're done editing, basically do the opposite to post the new attr back to the id field. Kind of wonky, but the performance of illustrator made it better than suffering with Inkscape for me -

from bs4 import BeautifulSoup

svg = open('myawesome.svg', 'r').read()

soup = BeautifulSoup(svg)

paths = soup.findAll('path')

for p in paths:
    p['inkscape:temp_id'] = p['id']

    html = p.prettify("utf-8")
    with open("output.svg", "a") as file:

The trick here is to open the original SVG in a text editor and replace the path's with the output of this script. When you're done in illustrator, copy this python script and copy 'inkscape:temp_id' back to p['id'] (the opposite of the first time) and then you're set.

Hope this helps someone out there. I wasted 4 hours today figuring out how to preserve element ID's in illustrator for a project I'm working on and this is the best I could come up with. Good luck!

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .