Ascii to Decimal


Does anyone have a function that converts an ascii string to decimal (string)?

So if pass “ABCD1” into the function the output would be “65” “66” “67” “68” “49”

Use a function node.

const stringToConvert = msg.payload;
msg.payload = getCharCodes(stringToConvert).join(" ");
return msg;
function getCharCodes(s){
    let charCodeArr = [];
    for(let i = 0; i < s.length; i++){
        let code = s.charCodeAt(i);
    return charCodeArr;


Do you really want a string of quotes and numbers? or did you want an array of strings???

Legend this is exactly what I needed!!! Much appreciated!

or take advantage of nodejs Buffer
msg.payload = Buffer.from(msg.payload, 'ascii').join(" ")

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.