prompt

Code Translator

Translates code from one language to another idiomatically, not line-for-line.

VettedUpdated June 2026
The prompt
You are a polyglot engineer. Translate the code below from {{from_lang}} to {{to_lang}}.

Inputs:
- Source code: {{code}}
- From: {{from_lang}} \u2192 To: {{to_lang}}
- Notes/constraints: {{notes}} (target framework, style, libs to use/avoid)

Produce:
1. The translated code, written idiomatically for {{to_lang}} \u2014 not a literal line-by-line port.
2. A short note on the key differences you handled (e.g. error handling style, async model, list comprehension vs loop, manual memory vs GC).
3. Any standard-library or idiom swaps you made and why.
4. A flag on anything that has no clean equivalent in {{to_lang}}, with the closest approach.

Rules: produce idiomatic {{to_lang}}, not transliterated {{from_lang}}; preserve behavior exactly; use {{to_lang}}'s conventions (naming, error handling, types); don't introduce a dependency unless {{notes}} allow it; flag any behavior that could subtly differ (integer division, default mutability, etc.).
Did it work? Rate this prompt

Variables

{{code}}Source code
{{from_lang}}From language
{{to_lang}}To language
{{notes}}Notes/constraints

Example output

From Python \u2192 To JavaScript. Code: a function that reads a list of dicts and returns names where age > 18. JavaScript: function adultNames(people) { return people .filter((p) => p.age > 18) .map((p) => p.name); } Key differences: - Python's list comprehension became filter().map() \u2014 the idiomatic JS equivalent. - Dict access p["age"] became property access p.age, standard for JS objects. - No type coercion added, but note: if age could be a string from JSON, Python's > would error while JS would compare loosely \u2014 coerce with Number(p.age) if the data isn't trusted. No missing equivalents here. Flag: if the original relied on Python ints being arbitrary-precision, JS numbers are floats \u2014 fine for ages, relevant for very large integers.

Details

Author

AI Khazna

License

Security

Vetted

Type

prompt

Related assets

More curated picks in Development & Code.

Audit before you install

Run any source through our checks - AI visibility, security, performance, and stack detection.

More in Development & Code