EnergyPlus running in your browser with WebAssembly
EnergyPlus, compiled to WebAssembly
→ To try it directly in your browser: see end of page!
I compiled EnergyPlus to WebAssembly using Emscripten. Load an IDF, pick an EPW weather file, edit the model inline with syntax highlighting, and run a full simulation — entirely client-side, with no install and no server involved.
How WebAssembly works
WebAssembly (WASM) is a binary instruction format that runs in the browser at near-native speed. It
is not JavaScript: it is a compilation target for languages like C, C++, or Rust. The browser
downloads a .wasm binary and some .js glue code, instantiates it in a sandboxed virtual machine, and executes it — with
access to memory but no direct access to the filesystem or the network.
Emscripten is the toolchain that compiles C/C++ to WebAssembly. It also provides a virtual filesystem (so EnergyPlus can read/write files as it normally would), and lets you export C functions so they can be called directly from JavaScript.
Getting EnergyPlus to compile
EnergyPlus is a large, mature C++ codebase, and getting it to compile with Emscripten required several non-trivial changes:
- Outdated dependencies — some third-party libraries refused to compile with Emscripten since my emcc compiler (5.0.2) is based on bleeding edge clang (23.0.0)
- Exported symbols — the EnergyPlus C API functions needed to be explicitly listed for Emscripten to expose them to JavaScript rather than dead-stripping them.
- I then had to figure out how to call those exported functions from the browser
The proof of concept is sound. The resulting .wasm binary is ~16 MB and loads in around 300 ms
on a typical connection — fast enough to feel instant.
Performance
Surprisingly, the simulation itself runs with no significant slowdown compared to a native
binary. WebAssembly executes at near-native speed: the browser JIT-compiles the WASM bytecode to
machine code on first load, and subsequent execution is essentially as fast as native C++. For the
bundled 1ZoneUncontrolled example (a simple single-zone model with a full-year Chicago weather
file), the simulation completes in a few seconds.
The main overhead is the initial .wasm download and instantiation (~300 ms), not the simulation
itself.
The EnergyPlus API opens the door to powerful workflows
What makes this more than just a curiosity is that the EnergyPlus C API is fully available inside the browser.
This opens up workflows that were previously only possible server-side or with a local EnergyPlus install:
- Interactive parametric studies — tweak the IDF, re-run, compare results without leaving the browser.
- Training and education — no install friction; students can run and modify real EnergyPlus models immediately.
- Model debugging — validate an IDF, inspect
Output:Variableobjects, readeplusout.errwith syntax highlighting, all in one place. - Embeddable demos — a simulation tool that can be embedded in any webpage, with no backend infrastructure.
The real-time chart plots any output variable you query via the API callback, updating as the simulation progresses through the year.
Try it
→ Run EnergyPlus in your browser
A default 1ZoneUncontrolled.idf model with a Chicago TMY3 weather file is pre-loaded, but you can load any IN/EPW from disk.
I’m even providing an IDF editor where you can modify the IDF content, with the Highlight.js grammar for EnergyPlus IDF I have created for E+ IDF/eplusout.err files, and rerun your simulation.
The tool exposes an EMS Callback editor: you write a JavaScript snippet that gets called at each zone timestep (one is provided for you, you can also delete the default one), with access to the full EnergyPlus API — reading output variables, setting actuators, querying simulation state. And this will update a d3.js chart! All from the browser, with results plotted in real time.
Hit Validate IDF, then Run EnergyPlus — the outdoor dry-bulb temperature and zone mean air temperature will be plotted live as EnergyPlus runs through the year.