Entity String Encoder/Decoder

This form converts entity-encoded strings to their decoded form, and vice versa.

The form requires JavaScript, which does not appear to be enabled in this browser (either that, or there's a catastrophic failure with your browser's DOM).  The code to perform encoding/decoding is fairly trivial and is listed below.

Entity String Decoder

This form converts entity-encoded strings to their decoded form.   The code to decode these strings is fairly trivial and is listed at the bottom of this form.  Note that this form will work with a mixture of entity-encoded and regular characters.

To encode entity strings, use this form.

Encoded Text

Enter the entity-encoded string in the textarea below. 

Decoded Result

Entity String Encoder

This form converts strings to an entity-encoded form, where each character is represented by its numeric value.  The code to encode these strings is fairly trivial and is listed at the bottom of this form.

To decode entity strings, use this form.

Source Text

Enter the string to entity encode in the textarea below. 

Encoded Result

Source Code


function encodeEntityString(source) {

    if (source == null) return "";
    var output = "";

    for (var i=0; i<source.length; i++) {
        output += "&#" + source.charCodeAt(i) + ";";
    }
    return output;
}

function decodeEntityString(source) {
// based on http://andrewu.co.uk/clj/entityencode
    if (source == null) {
        return "";
    } else {
        return source.replace(/&#(\d+);/gi,
                              function(a,b){return String.fromCharCode(b);}
                             );
    }
}