prompt
Code Translator
Translates code from one language to another idiomatically, not line-for-line.
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.).
Variables
{{code}}Source code{{from_lang}}From language{{to_lang}}To language{{notes}}Notes/constraintsExample 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
Frequently asked questions
What is the Code Translator prompt?
Translates code from one language to another idiomatically, not line-for-line.
Is Code Translator free?
Yes, it is free to use.
Related assets
More curated picks in Development & Code.
Refactors code for readability and structure while preserving behavior, with rationale.
Turns a bug report into a structured debugging plan with hypotheses and checks to isolate the cause.
Reviews a code diff or snippet for bugs, security, readability, and edge cases.
Generates unit tests for a function, including edge cases and failure paths.
Writes a clear PR description with summary, changes, testing, and review notes from a diff or change list.
Writes docstrings, inline comments, and README sections for existing code.
Audit before you install
Run any source through our checks - AI visibility, security, performance, and stack detection.
AI Agent / MCP Server Tester
ai testing
Automated Web Security Scan
security
AI Content Quality Test
arabic content
Site Stack Detector
migration
PageSpeed Analyzer
performance
AI SEO / AEO / GEO Audit
ai visibility
llms.txt Generator
ai visibility
Schema / JSON-LD Builder
ai visibility
Readability Score
arabic content
AI Cost Calculator
ai testing
Headline Analyzer
arabic content