# Built-in Base64 and Hex encode / decode

**URL:** <https://es.discourse.group/t/built-in-base64-and-hex-encode-decode/499>\
**Category:** 💡 Ideas\
**Created:** [October 10, 2020, 8:30am UTC](https://es.discourse.group/t/built-in-base64-and-hex-encode-decode/499 "2020-10-10T08:30:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![septs](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/septs/32/395_2.png) [@septs](https://es.discourse.group/u/septs)\
**Post date:** [October 10, 2020, 8:30am UTC](https://es.discourse.group/t/built-in-base64-and-hex-encode-decode/499/1 "2020-10-10T08:30:42Z")

</div>

```javascript
ArrayBuffer.from(input: string, type: "base64" | "hex"): ArrayBuffer
ArrayBuffer.toString(input: ArrayBuffer, type: "base64" | "hex"): string

```

but i need re-define `ArrayBuffer.prototype.toString`, the is break the web.

it is type checking method, `buffer.toString() === "[object ArrayBuffer]"`

---

<div class="post-metadata">

**Author:** ![Rudxain](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/rudxain/32/2272_2.png) [@Rudxain](https://es.discourse.group/u/Rudxain)\
**Post date:** [October 3, 2022, 6:21pm UTC](https://es.discourse.group/t/built-in-base64-and-hex-encode-decode/499/2 "2022-10-03T18:21:50Z")

</div>

I would love this. I always wondered why JS only has `atob` and `btoa` but no hex conversion

---

<div class="post-metadata">

**Author:** ![ljharb](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/ljharb/32/8_2.png) [@ljharb](https://es.discourse.group/u/ljharb)\
**Post date:** [October 3, 2022, 6:46pm UTC](https://es.discourse.group/t/built-in-base64-and-hex-encode-decode/499/3 "2022-10-03T18:46:18Z")

</div>

JS doesn't have those; those are in HTML.

---

<div class="post-metadata">

**Author:** ![Rudxain](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/rudxain/32/2272_2.png) [@Rudxain](https://es.discourse.group/u/Rudxain)\
**Post date:** [October 4, 2022, 9:09pm UTC](https://es.discourse.group/t/built-in-base64-and-hex-encode-decode/499/4 "2022-10-04T21:09:28Z")

</div>

> [@ljharb](#):
>
> those are in HTML

True, I was quite surprised when I read the spec now. It would be nice if the ES spec had these (but named better)

---

<div class="post-metadata">

**Author:** ![Jamesernator](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/jamesernator/32/538_2.png) [@Jamesernator](https://es.discourse.group/u/Jamesernator)\
**Post date:** [October 25, 2022, 3:18am UTC](https://es.discourse.group/t/built-in-base64-and-hex-encode-decode/499/5 "2022-10-25T03:18:45Z")

</div>

It doesn't cover hex, but there is already a stage 1 proposal for [Base64 array buffer support](https://github.com/tc39/proposal-arraybuffer-base64).
