// language-transpile

Translate a documented subset of Python to JavaScript and back — fully client-side, deterministic, no external calls.

Part of the CodeIntel tools roadmap — built for the blog, not for production.

// output will appear here

// how-it-works

01

Line + indentation rewriter

The engine walks the source line by line and rewrites each line against a documented subset of syntax patterns. It is not a full parser — it is a deterministic rewriter.

02

Indentation ↔ braces

Python indentation becomes JS braces on the way in; JS braces become Python indentation on the way out. A small stack tracks open blocks in both directions.

03

Pattern-level rewriters

Keywords, operators, and builtins are rewritten at the pattern level: print → console.log, len(x) → x.length, and / or / not → && / || / !.

04

Not a compiler

Unsupported constructs — classes, async/await, lambda, destructuring — are left verbatim and flagged in the annotations list. The tool is honest about its limits.

// supported-subset

This tool deliberately translates a small, documented subset. Anything outside this list is left verbatim and flagged in the annotations panel.

Python → JavaScript

PythonJavaScript
def name(a, b):function name(a, b) {
if cond:if (cond) {
elif cond:} else if (cond) {
else:} else {
while cond:while (cond) {
for i in range(n):for (let i = 0; i < n; i++) {
for i in range(a, b):for (let i = a; i < b; i++) {
for x in xs:for (const x of xs) {
print(x)console.log(x)
True / False / Nonetrue / false / null
and / or / not&& / || / !
len(x)x.length
x.append(y)x.push(y)
# comment// comment
x = exprlet x = expr; (or x = expr; if declared)

JavaScript → Python

JavaScriptPython
function name(a, b) {def name(a, b):
if (cond) {if cond:
} else if (cond) {elif cond:
} else {else:
while (cond) {while cond:
for (let i = 0; i < n; i++) {for i in range(n):
for (const x of xs) {for x in xs:
console.log(x);print(x)
true / false / nullTrue / False / None
&& / || / !and / or / not
=== / !==== / !=
x.push(y)x.append(y)
x.lengthlen(x)
// comment# comment
let x = y; / const x = y;x = y