I'm not sure if this is regular behavior, but when I do an SVG export in Illustrator, each layer name I have that is a number with be converted to a format I don't quite understand. I'm creating an SVG of a building map, so there are several sublayers that I've named the room number for each room.

When it exports, I'll have a room number of something like 100 and a layer for everything pertaining to that room, but the exporting id will be named _x31_00 and a room of 213 will become _x32_13.

I could understand if it didn't like an id starting with a number, but I don't understand why it would need to further add the underscore in the middle of the id (to make something like _x3213 or _x3_213).

I suppose I could change all the layers to something like Rm100, but I'd want to try to avoid work-arounds if at all possible.

My questions are

  1. Is there a way to change this behavior in the configuration? and
  2. If this is intentional by the program, I was just curious about the reasoning behind "_x3" (it's always hard to google for small amounts of characters, especially with special characters in it)
  • 2
    I am not entirely sure, but it appears that an SVG id tag is of the type NCName, and it looks to me like that an NCName value cannot begin with a number (?) ( stackoverflow.com/questions/1631396/… ). The replacement value you see may be e.g. an internal array index for the layer/group in question (element 13 on layer 32).
    – Yorik
    Jun 23, 2015 at 16:43
  • Did you get an answer to this, as I need to understand this too. I need my manually numbered paths to retain the IDs I have given them instead of Adobe adding these long prefixes which are of no use to my client. Cheers. Mar 11, 2016 at 13:19

1 Answer 1


As per comment by @Yorik apparently SVG standard defines id as a NCName which is Name with no colons allowed. Now a xml name can not start with a number as per XML standard. It also disallows other chars such as - and ..

Having a name that starts with a number will automatically invokes name mangling to make the name standards compilant. Not doing this could be disastrous, as XML forbids accepting malformed XML for further processing. So a svg renderer might not render the svg at all if the name does not match the standard and be doing completely the right thing.

Easiest solution is to simply rename the offending names to something that is valid like changing 99 to r99 or something similar (note name normalization applies if you use a underscore). Doing this after the fact is a bit tedious so i wrote a script for you to fix this:

#target illustrator

function is_numeric(str){
    return /^\d+$/.test(str);

var doc = app.activeDocument;
var itemCount = doc.pageItems.length;
for (var j = 0; j < itemCount; j++) {
    item = doc.pageItems[j];
    if (is_numeric(item.name[0]))
        item.name = "r" + item.name;

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.