Paste code → pick source & target language → get translated code. / 粘贴代码 → 选语言 → 得到翻译后的代码。
LangBridge is a dual-engine code translator: a rule engine for 9 language pairs (zero-dependency, instant), and an AI engine for any language pair (via DeepSeek API).
Open web/index.html in your browser — paste code, pick languages, click convert.
浏览器打开 web/index.html — 粘贴、选语言、转换。
# Rule engine (instant, no API key needed)
node bridge.js py2js app.py # Python → JavaScript
node bridge.js json2go schema.json # JSON → Go struct
node bridge.js js2ts app.js # JS → TypeScript
node bridge.js sql2json schema.sql # SQL DDL → JSON Schema
# AI engine (any pair, needs API key)
node bridge.js ai py2cpp algorithm.py --key sk-xxx
node bridge.js ai java2py Main.java| Source / 源 | Target / 目标 | Pair / 语言对 |
|---|---|---|
| 🐍 Python | 📜 JavaScript | py2js |
| 📜 JavaScript | 🐍 Python | js2py |
| 📜 JavaScript | 📘 TypeScript | js2ts |
| 📘 TypeScript | 📜 JavaScript | ts2js |
| 📋 JSON | 🔵 Go struct | json2go |
| 📋 JSON | 🦀 Rust struct | json2rs |
| 📋 JSON | 🟣 C# class | json2cs |
| 📋 JSON | ☕ Java class | json2java |
| 🗄️ SQL DDL | 📋 JSON Schema | sql2json |
For any language pair not in the rule engine (e.g., Python → C++, Java → Python, Ruby → JS), use AI mode:
# Set your API key
export DEEPSEEK_API_KEY=sk-xxx
# Translate anything
node bridge.js ai py2cpp algorithm.py
node bridge.js ai rb2js script.rbGet a free API key: platform.deepseek.com
Features:
- ✅ Split-pane editor (input left, output right)
- ✅ 10+ language selectors
- ✅ Rule engine (instant) + AI mode toggle
- ✅ One-click copy & download
- ✅ Works offline (rule engine only)
- ✅ Dark theme
Most code translators are either:
- Too simple — regex find/replace, fails on real code
- Too heavy — require installing compilers, transpilers, and 500 npm packages
LangBridge is different:
- Rule engine: Heuristic pattern matching covering 90% of real-world code patterns. Zero dependencies, instant results.
- AI engine: LLM-powered for the remaining 10% — complex cross-paradigm translations.
You choose the right tool for the job.
MIT