Skip to content

A curated list of awesome transpilers. aka source-to-source compilers

License

Notifications You must be signed in to change notification settings

milahu/awesome-transpilers

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 

Repository files navigation

Awesome Transpilers

By Target Language

Golang

  • c2go A tool for transpiling C to Go.
  • Grumpy Grumpy is a Python to Go source code transcompiler and runtime.

Java

  • VOC A transpiler that converts Python code into Java bytecode.

JavaScript

  • Shift.JS Swift to JavaScript transpiler.
  • ElixirScript Converts Elixir to JavaScript.
  • GopherJS A compiler from Go to JavaScript for running Go code in a browser.
  • Dart2js Use the dart2js tool to compile Dart code to deployable JavaScript.

Transpilers

TypeScript Compiler

Babel

  • https://github.com/babel/babel - 40K stars
  • compile new versions of JavaScript (ES2020) to old versions of JavaScript (ES2015)
  • written in: TypeScript, JavaScript
  • compiles from: JavaScript
  • compiles to: JavaScript
  • last commit: 2023

eslint

Nim

ClojureScript

jscodeshift

  • https://github.com/facebook/jscodeshift - 8K stars
  • toolkit for running codemods over multiple JavaScript or TypeScript files
  • codemods = refactoring
  • written in: JavaScript
  • compiles from: JavaScript
  • compiles to: JavaScript
  • last commit: 2023

ast-grep

  • https://github.com/ast-grep/ast-grep - 5K stars
  • CLI tool for code structural search, lint and rewriting
  • "grep for code"
  • "grep for AST nodes"
  • based on tree-sitter parsers
  • written in: Rust
  • compiles from: all languages
  • compiles to: all languages

c2rust

andrei-markeev/ts2c

OneLang

  • https://github.com/onelang/OneLang - 1K stars
  • written in: TypeScript
  • compiles from: TypeScript, C#, Ruby
  • compiles to: C++, C#, Go, Java, JS, Perl, PHP, Python, Ruby, Swift, TypeScript
  • last commit: 2021

cheerp

Haxe

QQuick/Transcrypt

winemaker

Js2Py

Fennel

Cito

  • https://github.com/pfusik/cito - 1.5K stars
  • one to many
  • written in: C#
  • compiles from: Cito
  • compiles to: C, C++, C#, Java, JavaScript, Python, Swift, TypeScript, OpenCL C

TypeScriptToLua

jingweno/godzilla

cincheo/jsweet

google/j2cl

Pebaz/nimporter

pseudo-lang

  • https://github.com/pseudo-lang/pseudo - 700 stars
  • one to many
  • generate readable code
  • help with automated translation for cases like algorithm generation, parser generation, refactoring, porting codebases
  • written in: Python
  • compiles from: Pseudo
  • compiles to: Python, JavaScript, Go, C#, C++, Ruby
  • last commit: 2021

LingDong-/wax

  • https://github.com/LingDong-/wax - 600 stars
  • A tiny programming language
  • written in: C
  • compiles from: Wax
  • compiles to: C, C++, Java, TypeScript, Python, C#, Swift, Lua, WebAssembly
  • last commit: 2022

TypeScript2Cxx

putout

webcrack

wakaru

jsxx

ben-sb/obfuscator-io-deobfuscator

StaticScript

ts-llvm

muta-minits

transpyle

speedy.js

futurGH/ts-to-jsdoc

ccxt/crosspile

  • https://github.com/ccxt/crosspile - 60 stars
  • A cross-compiler from JavaScript to any language (currently, Python and PHP) // WORK IN PROGRESS (early stages)
  • written in: JavaScript
  • compiles from: JavaScript
  • compiles to: PHP, Python
  • last commit: 2017

bash2py

  • https://github.com/clarity20/bash2py - 30 stars
  • https://www.swag.uwaterloo.ca/bash2py/
  • Bash to Python script translator, implemented by modifying the bash C code, so that instead of executing bash commands, the modified tool simply emits (to the extent currently possible) the commands seen as equivalent Python statements.
  • written in: C
  • compiles from: Bash
  • compiles to: Python
  • last commit: 2023

ccxt/ast-transpiler

  • https://github.com/ccxt/ast-transpiler - 20 stars
  • AST Transpiler that converts Typescript into different languages (PHP, Python, C# (wip))
  • written in: TypeScript
  • compiles from: TypeScript
  • compiles to: PHP, Python
  • last commit: 2024

sebbekarlsson/typescript

sebbekarlsson/tscc

andrejusk/typescript-compiler

yakir22/ts2cpp

duncanhorn/ts2cpp

quadramadery/js2py

tython

7HR4IZ3/es62py

  • https://github.com/7HR4IZ3/es62py - 0 stars
  • written in: Python
  • based on: esprima-parser, js2py library
  • compiles from: JavaScript (ECMA 6)
  • compiles to: Python
  • last commit: 2023
  • status: early draft

prometeo

py2many

pyo3

  • https://github.com/PyO3/pyo3 - 7K stars
  • Rust bindings for the Python interpreter
  • no transpiler
  • use cases: write native Python modules in Rust, embed Python in a Rust binary

ts2nim

clojurec

hissp

kalai

Cerberus X Trans

roman01la/javascript-to-clojurescript

basilisp

Kotlift

andreikop/cpp2python

seasnake

Progsbase

TODO what exactly is this? a transpiler service?

  • https://www.progsbase.com/
  • "Job Payments: You can create programming jobs using the progsbase client. Create payments here to reward developers who implement a solution to your job."
  • closed source
  • Free Community Plan: convert TypeScript, Java, C, C++, JavaScript, C#, PHP, Python, Visual Basic, Swift, LibreOffice Basic, Ruby, Visual Basic
  • written in: Java, Progsbase
  • compiles from: Java
  • compiles to: Java, C, C++, JavaScript, C#, R, PHP, Python, Visual Basic
  • since: 2018

jtransc

specs-feup/clava

  • https://github.com/specs-feup/clava - 50 stars
  • applies analysis and transformations written in LARA scripts (which is based on JavaScript)
  • based on: Clang
  • written in: Java
  • languages: C, C++, CUDA, OpenCL
  • last commit: 2022

RapidFingers/Craxe

Ranger

https://github.com/terotests/Ranger - 5 stars

  • written in: JavaScript
  • self hosting
  • compiles from: Ranger?
  • compiles to: JavaScript, Java, Go, Swift, PHP, C++, C#, Scala
  • last commit: 2018

cxx2cs

https://sourceforge.net/projects/cxx2cs/

  • compiles from: C++
  • compiles to: C#
  • last commit: 2015

J2CL

https://github.com/google/j2cl - 1K stars

GWT

SequalsK

python scripts to python modules

lezer-parser-import-tree-sitter-scanner

  • https://github.com/milahu/lezer-parser-import-tree-sitter-scanner
  • Helps import tree-sitter grammars and scanners.
  • A grammar transpiler, and a domain-specific C++ to JavaScript transpiler.
  • Import ANTLR grammars to lezer-parser
  • written in: JavaScript
  • compiles from: C++, tree-sitter grammars, ANTLR grammars
  • compiles to: JavaScript, lezer-parser grammars

Transpiler Frameworks

can be used for all languages

comby

  • https://github.com/comby-tools/comby - 2K stars
  • A code rewrite tool for structural search and replace that supports about every language
  • written in: OCaml
  • languages: C, Java, Go, Swift, Rust, PHP, TypeScript, JavaScript, ...
  • features: refactoring

JetBrains MPS

rose compiler

  • https://github.com/rose-compiler/rose - 500 stars
  • languages: C (C89 and C98), C++ (C++98 and C++11), UPC, Fortran (77/95/2003), OpenMP, Java, Python, PHP
  • use cases: static analysis, program optimization, program transformation

jarble/transpiler

  • https://github.com/jarble/transpiler - 400 stars
  • translates a small subset of several programming languages into several others
  • translate several metasyntax notations, such as EBNF and ABNF
  • experimental "proof-of-concept," so it can only translate relatively simple programs
  • A major goal of this project is to translate TypeScript and JavaScript to other languages that compile to C or native code. For example, it's possible to translate a subset of TypeScript to Zig
  • written in: JavaScript
  • languages: JavaScript, Prolog, C, C#, PHP, Python, Lua, Perl, Haskell, Fortran, Java, OCaml, GLSL, ...

Rascal

true-grue/raddsl

LangTrans

  • https://github.com/LangTrans/LangTrans - 20 stars
  • Customize programming languages
  • written in: Python
  • features: parse, transform
  • syntactic preprocessor
  • customize the syntax of any programming language
  • based on: regex
  • last commit: 2022

codeworker

SemanticDesigns DMS Toolkit

  • https://www.semanticdesigns.com/Products/DMS/DMSToolkit.html
  • Software Reengineering Toolkit
  • closed source
  • languages: C++, Java, COBOL, SQL, HTML, Verilog, ...
  • written in: PARLANSE = parallel language. As an example, the attribute evaluation process is automatically parallelized, and can often provide a linear speedup on an N-way SMP system.

Code generators

Partial evaluators

aka: partial evaluation, code optimizers, code optimization, dead code elimination, tree shaking, code compression, code minification

JavaScript

SVG

CSS

Machine Learning

ChatGPT by OpenAI

  • https://chat.openai.com/
  • works online
  • requires login
  • limitation: can translate up to 31523 characters of code = about 30 KByte, so large inputs must be splitted into smaller chunks
  • start the chat with: can you translate from some_input_language to some_output_language?
    • can you translate from javascript to python?
    • can you translate from python to javascript?
    • ...
  • chatGPT will also transform symbol names, for example from camelCase in javascript to snake_case in python. this is hard to disable. you can ask "can you translate ... and preserve the original symbol names?" but then the output is truncated after 3K characters
  • on large inputs, chatGPT will return an interpretation of what the code is doing
    • answer: yes. can you translate the code to some_output_language?
      • yes. can you translate the code to python?
      • yes. can you translate the code to javascript?
      • ...
    • the output will pause, then click: continue generating
  • languages: many
  • based on Codex
    • what language model is used by chatgpt to translate between programming languages?
      • As of my last update in January 2022, ChatGPT does not directly translate between programming languages. However, OpenAI has developed models capable of code generation and understanding code in various programming languages, such as Codex, which powers GitHub Copilot. These models are trained on large datasets of code and natural language to understand and generate code snippets based on human-written descriptions or code prompts. While ChatGPT itself may not directly perform programming language translation, it can be used in conjunction with such code generation models to facilitate communication or provide assistance in programming-related tasks.

code converter by codingfleet

  • https://codingfleet.com/code-converter/python/
  • works online
  • requires login for 5000 characters, otherwise only 1000 characters
  • https://codingfleet.com/pricing/
    • free account: 5K characters per request, 10 requests per month
    • pro account: 32K characters per request
      • 5 usd / month = 50 requests per month
      • 10 usd / month = 200 requests per month
      • 24 usd / month = 1000 requests per month
    • unlimited account: 200 usd / year: 64K characters per request
  • Languages: ABAP, APL, Ada, Assembly, Bash, C, C#, C++, COBOL, Clojure, CommonLisp, Crystal, Dart, Elixir, Elm, Erlang, F#, Fortran, Go, Groovy, Haskell, Java, Javascript, Julia, Kotlin, Lua, MATLAB, Nim, Node.js, OCaml, Objective-C, PHP, Pascal, Perl, PowerShell, Prolog, R, Ruby, Rust, SAS, SQL, Scala, Scheme, Swift, TypeScript, VHDL, Verilog, Zsh
    • Databases: BigQuery, IBM, Db2, MySQL, PL/SQL, PostgreSQL, Redshift, SQLite, Snowflake, T-SQL
    • Web Scraping: BeautifulSoup, Mechanize, Playwright, Puppeteer, Scrapy, Selenium
    • Web Programming: ASP.NET, Angular, CherryPy, Django, Express.js, FastAPI, Flask, Laravel, Pyramid, Rails, React, Spring, Symfony, VueJS
    • Deep Learning: Caffe, JAX, Keras, MXNet, PyTorch, TensorFlow, Theano

TransCoder by Facebook

  • https://github.com/facebookresearch/TransCoder - 1.5K stars
    • deprecated in favor of CodeGen
  • https://github.com/facebookresearch/CodeGen - 500 stars
  • based on: tree-sitter parsers
  • tags: ai, machine learning, generic, metaprogramming language, Metaprogramming System, transpiler framework
  • Create your own domain-specific language
  • generic transpiler, can be trained to translate all languages
  • written in: Python
  • license: MIT, Creative Commons Attribution-NonCommercial 4.0, Creative Commons Attribution-ShareAlike 2.0
  • languages: C++, Java, Python, ... any

OPT by Facebook

InCoder by Facebook

CodeGen by Salesforce

CodeT5 by Salesforce

PolyCoder

  • https://github.com/VHellendoorn/Code-LMs
  • tags: ai, machine learning
  • paper https://arxiv.org/pdf/2202.13169.pdf
  • This model was not trained to solve programming problems and may not perform well on a benchmark such as HumanEval.
  • Whitespace is very important to the model, since no preprocessing was done on the input files.
  • parameters: 2.7B
  • release: 2020-10
  • trained on: 12 programming languages (C, C#, C++, Go, Java, JavaScript, PHP, Python, Ruby, Rust, Scala, TypeScript)
  • architecture: GPT-2

GPT-3 by OpenAI

  • license: closed source (OINO = open in name only)
  • parameters: 175B
  • architecture: auto-regressive model for next token prediction
  • release: 2020-06-11
  • price: 0.06 USD / 1K tokens - https://openai.com/api/pricing/

CodeParrot

  • https://huggingface.co/codeparrot
  • CodeParrot is a GPT-2 model trained to generate Python code
  • parameters: 1.5B
  • architecture: GPT-2
  • Code generation with: CodeParrot (1.5B), InCoder (6B) and CodeGen (6B)
  • trained on: GitHub Code (32 programming languages), ...

GPT-Neo

  • trained on: The Pile
  • parameters: 2.7B

GPT-J by EleutherAI

GPT-NeoX by EleutherAI

AlexaTM by Amazon

Codex

  • tags: ai, machine learning
  • license: closed source
  • free trial: 18 USD credit
  • parameters: 12B

Jurassic-1 language model by AI21 labs

Megatron-Turing NLG by NVIDIA and Microsoft

BLOOM

  • decoder-only architecture
  • https://huggingface.co/docs/transformers/model_doc/bloom
  • license: closed source
  • 13 programming languages
  • trained on: 46 natural languages, 13 programming languages
  • parameters: 176B
  • architecture: auto-regressive model for next token prediction (similar to GPT3)

Online Transpilers

javainuse.com

code refactoring tools

code refactoring is not "transpiling" code from language A to language B,
but reshaping the program design from ugly to pretty code, while keeping the original language,
and while keeping the original behavior of the code (same inputs, same outputs)

examples:

ruff

rope

libcst

  • https://github.com/Instagram/LibCST - 1.5K stars
  • A concrete syntax tree parser and serializer library for Python that preserves many aspects of Python's abstract syntax tree
  • written in: Python
  • languages: Python
  • last commit: 2024

bowler

  • https://github.com/facebookincubator/bowler - 1.5K stars
  • Safe code refactoring for modern Python
  • status: deprecated
    • deprecated in favor of libcst: "If you need to do codemods today, we recommend looking at LibCST codemods which are a bit more verbose, but work well on modern python grammars."
  • written in: Python
  • languages: Python 3.8
  • last commit: 2023

CodART

  • https://github.com/m-zakeri/CodART - 30 stars
  • Source Code Automated Refactoring Toolkit
  • We have currently focused on automating the various refactoring operations for Java source codes.
  • A complete list of refactoring supported by CodART can be found at CodART refactorings list.
  • written in: Python
  • last commit: 2024

GitHub topics

See also

Releases

No releases published

Packages

No packages published