Mojo-js: A Mojo-to-JavaScript Transpiler Experiment

Hi everyone,

I’ve been playing around with Mojo’s syntax and decided to see how its “Systems-meets-Python” philosophy translates to the web. I’ve built a proof-of-concept transpiler called mojo-js.

The goal was simple: Could I take Mojo-flavored source code and map it directly to executable JavaScript?

What’s in the PoC:

  • Lexer and parser: A custom JS-based tokenizer that handles Mojo’s block scoping, and an AST parser

  • Basic Transpiler: Maps things like Mojo struct and fn signatures into equivalent JS patterns.

  • ~50 test cases for all the supported constructs, run automatically through CI/CD

  • The “Why”: It’s mostly a conceptual exploration of Mojo as an authoring language for the universal runtime of the browser, created through AI-assisted co-development.

Current Status: It’s very much “Phase 0”. I’ve been observing the discussions here regarding the language’s evolution (the fn vs def debates, etc.), and it’s clear we are in the early days. This project isn’t about chasing hardware-level performance in the browser; it’s about exploring the ergonomics of Mojo’s syntax in a new context.

Looking at the road map, I was thinking in particular the “clear error messages” part could benefit from a rapid community-driven iteration on a project like this: Define sample test cases of Mojo program snippets that currently result in cryptic error messages, prototype improvements

I’d love to hear if anyone else is thinking about Mojo for web-based tooling or distributed logic.

Demo: Igniting Mojo 🔥 on the Web
Source repo

2 Likes