AI prompts for Developers
Prompt to convert code from one language to another
Converts code to another language in its idiomatic style, noting behaviour differences and libraries with no direct equivalent.
When to use it When porting a tool or service to your team's language, or reusing an example written in a language you do not use.
The prompt, ready to copy
Role: developer fluent in [source language] and [target language]. Task: convert the code below to [target language and version]. Context: - Libraries allowed in the target: [list, or "standard library only"] - Team style: [e.g. async/await, strict types] Code: <source> [Original code, no secrets] </source> Constraints: - Write idiomatic target-language code, not a line-by-line translation - Keep the same behaviour, including error and null handling - If something behaves differently between the languages (division, encoding, dates, decimals), say so explicitly - Do not use a library you are not sure exists Output: 1. The converted code 2. Differences table: location | behaviour in source | behaviour in target | what you did 3. Suggested tests to confirm matching behaviour
Example of filled brackets
From Python to TypeScript (Node 22) Libraries: standard library only Code: a script that reads a CSV with Arabic names and totals per branch
Check these before you use it
- Run both on the same inputs and compare outputs
- Watch Arabic text encoding and decimal rounding
How to use this prompt
- Copy the prompt: Press the copy button or select the whole text.
- Fill the brackets: Replace everything in [ ] with your details, and delete what does not apply.
- Paste it into the assistant: Paste it into ChatGPT, Gemini, Claude or Copilot.
- Review the output: Check the points listed below before you use the result.