# Payload Formatting ---- Javascript basics

**URL:** <https://www.thethingsnetwork.org/forum/t/payload-formatting-javascript-basics/59344>\
**Category:** Application Development\
**Created:** [October 13, 2022, 12:31am UTC](https://www.thethingsnetwork.org/forum/t/payload-formatting-javascript-basics/59344 "2022-10-13T00:31:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ridgerunnersjw](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/ridgerunnersjw/32/35697_2.png) [@ridgerunnersjw](https://www.thethingsnetwork.org/forum/u/ridgerunnersjw)\
**Post date:** [October 13, 2022, 12:31am UTC](https://www.thethingsnetwork.org/forum/t/payload-formatting-javascript-basics/59344/1 "2022-10-13T00:31:56Z")

</div>

Hello all…  
I am using a SEEED Lora-E5 module and sending ASCII messages to the TTN (testing only)…The messages show up as hexadecimal. I would like to convert the message back to the ascii string. I am very new to this and have never used javascript. I “blindly” grabbed the following function from the internet and tried to add value to decodeUpLink but it doesn’t work…

```auto
 function decodeUplink(input) 
 {
	var t = input.toString();
	var str = '';
	for (var i = 0; i < t.length; i+=2)
	{
		str += String.fromCharCode(parseInt(t.substr(i, 2), 16));
	}
  return {
    data: {
      value: str
    },
    warnings: [],
    errors: []
  };
}

```

Example : Hello ---- 48 65 6C 6C 6F

gives me

```auto
{
  "value": "\u0000\u000bì\u0000\u0000\u0000\f\u0000"
}

```

Can someone tell me what I am missing here?

---

<div class="post-metadata">

**Author:** ![clv](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/clv/32/46568_2.png) [@clv](https://www.thethingsnetwork.org/forum/u/clv)\
**Post date:** [October 15, 2022, 12:37pm UTC](https://www.thethingsnetwork.org/forum/t/payload-formatting-javascript-basics/59344/2 "2022-10-15T12:37:29Z")

</div>

Test with numbers. No reason to send ASCII.

```auto
var input = '48656C6C6F';
var output = Buffer.from(input, 'hex');
console.log(input + " -> " + output);

```

Check the [documentation / tutorial](https://www.thethingsnetwork.org/docs/devices/bytes/#how-to-send-text).
