Code Converter

Code Converter: Port code without losing the idiom.

Translate between twelve languages using each one's conventions rather than transliterating syntax.

Source
1 line0 / 20,000js
JavaScript → Python
Target · Python

Nothing converted yet

Pick a target language and run. The output is written the way a senior engineer in that language would write it, not transliterated.

idle

Generated code has not been compiled or type-checked against your project. Read it, build it, and run your tests before shipping it.

What this instrument does

Translate code between twelve languages using each one's conventions rather than transliterating syntax line by line.

The difference shows up in error handling, iteration, null representation and the standard library. Those are the places where a transliteration is syntactically valid and behaviourally wrong.

How it works

Idiom over syntax
Idiomatic Go returns an error rather than throwing. Idiomatic Python uses a comprehension where JavaScript uses reduce. Idiomatic C# uses pattern matching. The output is written the way a senior engineer in the target language would write it.
Behaviour is preserved deliberately
Where the two languages genuinely differ, such as integer overflow, floating point, or mutation visible to callers, the difference is noted in a code comment rather than silently resolved.
Complete output
You get the whole converted unit, not a fragment, so the result can be compiled and run rather than eyeballed.

Questions about Code Converter

Questions
Which language pairs are supported?
Any combination of JavaScript, TypeScript, Python, Java, C#, C++, Go, Ruby, PHP, Rust, SQL and shell.
Is the converted code guaranteed to compile?
No. It is generated, not compiled, and it has not been type-checked against your project. Treat it as a reviewed first draft: read it, compile it, run your tests.
How is this different from a transpiler?
A transpiler operates on syntax with a formal grammar and guarantees an equivalent program. This is a model reasoning about meaning, which is what lets it produce idiomatic Python from Go, but it also means it can be confidently wrong. Use a transpiler when one exists for your pair.

All instruments

Other instruments