Convert code to another language or framework
Idiomatic translation of code between languages or frameworks, with notes on differences.
The prompt
Convert this code from [SOURCE LANGUAGE/FRAMEWORK] to [TARGET LANGUAGE/FRAMEWORK].
Code:
[PASTE]
Target version and constraints: [e.g. Python 3.12, no external libraries]
Rules:
- Write idiomatic code for the target, not a line-by-line transliteration.
- Preserve behavior exactly, including edge cases and error handling.
- Use standard-library or well-maintained equivalents for dependencies; name them.
Return the converted code, a table mapping key constructs (source → target), behavior differences to watch for (integer division, nulls, async, string encoding), and tests to verify the conversion.
Highlighted [brackets] are blanks to replace with your own details.
Fill in the blanks and use this promptMore Software Development prompts
What to fill in
- SOURCE LANGUAGE/FRAMEWORK
- TARGET LANGUAGE/FRAMEWORK
- PASTE
- e.g. Python 3.12, no external libraries
How this prompt is built
This prompt follows the RTF structure (Role, Task, Format). RTF tells the model who to be, what to do and what shape the answer should take. It is the quickest structure that still gives noticeably better results than a bare request.
Related prompts
- Write unit tests for my codeComprehensive unit tests covering happy paths, edge cases, and failures.
- Write documentation, a README, or API docsGenerates clear technical documentation from your code or notes.
- Write precise TypeScript types for my data and APIsSafer, readable TypeScript types that rule out impossible states, replace unsafe casts, and come with compile-time tests.
- Write a style guide that documents my app's existing design codeReverse-engineers colors, typography, spacing, and component patterns from your codebase into a STYLE_GUIDE.md developers and AI agents can follow.