# Eval in makecode

**URL:** https://forum.makecode.com/t/eval-in-makecode/45114
**Category:** Collaboration
**Tags:** javascript, extension, make, demo, game
**Created:** [July 28, 2026, 9:05pm UTC](https://forum.makecode.com/t/eval-in-makecode/45114 "2026-07-28T21:05:35Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![VoxelMaster64](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/voxelmaster64/32/32075_2.png) [@VoxelMaster64](https://forum.makecode.com/u/VoxelMaster64)
#### Post date: [July 28, 2026, 9:05pm UTC](https://forum.makecode.com/t/eval-in-makecode/45114/1 "2026-07-28T21:05:35Z")

</div>

Something I have been trying to do recently was getting `eval` into makecode. This sounds hard or impossible to do if you are not familiar with shims, and sounds easy when you are. In Javascript, `eval` is a function that executes Javascript. So `eval("console.log(1);")` logs `1` to the console, `eval("let t = eval("['a', 'b', 'c'].join()");")` makes a variable t with the data `abc`, etc. Since `eval` is not a function in makecode, I first searched and found that [this file](https://github.com/microsoft/pxt/blob/7c43ebf85e9b9ecdc0c7c97ffc9e40ee0c85caf4/pxtsim/runtime.ts#L1635) is the only file that has eval in a way that you can shim it. The only issue is that it’s inside `pxsim.Runtime`’s constructor, and it’s impossible to shim a class. Thankfully, I found that [this file](https://github.com/microsoft/pxt/blob/7c43ebf85e9b9ecdc0c7c97ffc9e40ee0c85caf4/pxtsim/embed.ts#L430) calls that constructor. In that function, `msg` is a `SimulatorRunMessage`, which is an `interface`, another thing you can’t shim. You can pass an `object` instead of an `interface`, and it will work fine. Sadly, when you create an `object` in makecode, it gets turned into a `RefMap`, which is a class and is defined [here](https://github.com/microsoft/pxt/blob/7c43ebf85e9b9ecdc0c7c97ffc9e40ee0c85caf4/pxtsim/langsupport.ts#L349). I have no idea how to pass in an object and not a `RefMap`, though. There is a `toAny` function attached to `RefMap`, but I don’t know how to call it. Does anybody have any suggestions? [Here](https://arcade.makecode.com/S98952-25347-31084-43902) was my attempt at it. Also, if you want to help, use `devTools`. In the console, you should see an error when playing my attempt. If you click the upper-most link on the error, it should send you to `const entryPoint = ...`. If not, then hit `ctrl+f` and type `eval(msg.code)`. Place a breakpoint on that line. Then, play the simulator. when it finishes, if you type `msg.code` in the simulator then you can see an the code. you can do `console.log(msg.code.replaceAll("\\n", "\n"))`, then click `copy` (I forgot what the actual button is called) and paste it to something like `notepad`. The total code is around `1.9 MB`, an empty project is `1.8 MB`, and `2.1MB` is probably the highest anything gets. If I do discover something, then I would make this an extension. Although, the `@moderators` would probably stop it from being possible.

---

<div class="post-metadata">

### Author: ![jwunderl](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jwunderl/32/5308_2.png) [@jwunderl](https://forum.makecode.com/u/jwunderl)
#### Post date: [July 28, 2026, 9:06pm UTC](https://forum.makecode.com/t/eval-in-makecode/45114/2 "2026-07-28T21:06:32Z")

</div>

no, this is never something that is going to be allowed, this is something we specifically _avoid_ allowing for security. If you want to do something like that it has to be something you control (e.g. github pages page with message passing), but then there’s pretty much no reason to do so in the first place.

---

<div class="post-metadata">

### Author: ![VoxelMaster64](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/voxelmaster64/32/32075_2.png) [@VoxelMaster64](https://forum.makecode.com/u/VoxelMaster64)
#### Post date: [July 29, 2026, 2:22am UTC](https://forum.makecode.com/t/eval-in-makecode/45114/3 "2026-07-29T02:22:54Z")

</div>

> [@jwunderl](#):
>
> this is never something that is going to be allowed

that’s what I thought
