# Converting from js to kotlin

**URL:** <https://discuss.kotlinlang.org/t/converting-from-js-to-kotlin/17814>\
**Category:** JavaScript\
**Created:** [May 24, 2020, 9:26am UTC](https://discuss.kotlinlang.org/t/converting-from-js-to-kotlin/17814 "2020-05-24T09:26:17Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ananiya-Jemberu](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@Ananiya-Jemberu](https://discuss.kotlinlang.org/u/Ananiya-Jemberu)\
**Post date:** [May 24, 2020, 9:26am UTC](https://discuss.kotlinlang.org/t/converting-from-js-to-kotlin/17814/1 "2020-05-24T09:26:17Z")

</div>

hi there, have any idea about converting js(java script) to kotlin/js any thing plugin, tool or library?

---

<div class="post-metadata">

**Author:** ![Wasabi375](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/wasabi375/32/4741_2.png) [@Wasabi375](https://discuss.kotlinlang.org/u/Wasabi375)\
**Post date:** [May 24, 2020, 10:55am UTC](https://discuss.kotlinlang.org/t/converting-from-js-to-kotlin/17814/2 "2020-05-24T10:55:51Z")

</div>

I don’t think it’s possible, not really. JS doesn’t have any type information and kotlin is strongly typed. Such a tool would need to guess every single type for every single expression, based only on how it is used. This is pretty much impossible.  
Converting type script however should be possible, but I don’t think there are any tools out there. At least I don’t know any.

---

<div class="post-metadata">

**Author:** ![darksnake](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/darksnake/32/2479_2.png) [@darksnake](https://discuss.kotlinlang.org/u/darksnake)\
**Post date:** [May 24, 2020, 11:30am UTC](https://discuss.kotlinlang.org/t/converting-from-js-to-kotlin/17814/3 "2020-05-24T11:30:56Z")

</div>

I do not think it is possible to convert general JS code to kotlin. The languages are far too different for that. It is not even possible to write nice kotlin wrappers for JS.

---

<div class="post-metadata">

**Author:** ![rjaros](https://avatars.discourse-cdn.com/v4/letter/r/9f8e36/32.png) [@rjaros](https://discuss.kotlinlang.org/u/rjaros)\
**Post date:** [May 24, 2020, 12:01pm UTC](https://discuss.kotlinlang.org/t/converting-from-js-to-kotlin/17814/4 "2020-05-24T12:01:56Z")

</div>

It could be possible to create a translator with lots of `dynamic` types on the Kotlin side.

---

<div class="post-metadata">

**Author:** ![lamba92](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/lamba92/32/5089_2.png) [@lamba92](https://discuss.kotlinlang.org/u/lamba92)\
**Post date:** [May 24, 2020, 4:10pm UTC](https://discuss.kotlinlang.org/t/converting-from-js-to-kotlin/17814/5 "2020-05-24T16:10:58Z")

</div>

Yeah but that would not be Kotlin! What’s the point? Better to keep JS as is and provide externals!

---

<div class="post-metadata">

**Author:** ![peterhenryd](https://avatars.discourse-cdn.com/v4/letter/p/90db22/32.png) [@peterhenryd](https://discuss.kotlinlang.org/u/peterhenryd)\
**Post date:** [May 25, 2020, 1:17am UTC](https://discuss.kotlinlang.org/t/converting-from-js-to-kotlin/17814/6 "2020-05-25T01:17:30Z")

</div>

To add to other points, the general coding styles of Kotlin and JavaScript are very different. A converter would be completely useless unless you would like to generate badly written code.
