# Convert Principal to subaccount ID in TS (code sample)

**URL:** https://forum.dfinity.org/t/convert-principal-to-subaccount-id-in-ts-code-sample/13144
**Category:** Developers
**Tags:** JavaScript, TypeScript
**Created:** [May 20, 2022, 10:04am UTC](https://forum.dfinity.org/t/convert-principal-to-subaccount-id-in-ts-code-sample/13144 "2022-05-20T10:04:05Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![1eo](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/1eo/32/25778_2.png) [@1eo](https://forum.dfinity.org/u/1eo)
#### Post date: [May 20, 2022, 10:04am UTC](https://forum.dfinity.org/t/convert-principal-to-subaccount-id-in-ts-code-sample/13144/1 "2022-05-20T10:04:05Z")

</div>

Convert Principal to subaccount ID in TS or JS. This is an issue that I had, I just wanted to share the code that I made as I wasn’t able to find it anywhere.  
Here is my code sample :

> **[GitHub - leo-ship-it/convert-principal-to-subaccount-IC](https://github.com/leo-ship-it/convert-principal-to-subaccount-IC)**
>
> Contribute to leo-ship-it/convert-principal-to-subaccount-IC development by creating an account on GitHub.
