Code language converter prompt: port code fast
Paste code in one language and get an equivalent, idiomatic version in another, with notes on any tricky conversions.
متى تستخدم هذا البرومبت
- When migrating a script from Python to JavaScript or similar.
- When prototyping in one language before porting to production.
- When comparing how the same algorithm looks in two languages.
نص البرومبت
Convert the following {{language}} code to {{framework}}, preserving logic and behavior exactly. Note any language-specific idioms or libraries used in the conversion.
{{CLIPBOARD}}{{language}}{{framework}}{{CLIPBOARD}}الكتلة {{CLIPBOARD}} تُستبدل تلقائياً بما نسخته قبل الضغط على «نسخ».
كيف تستخدمه
- انسخ البرومبت بالزر أو املأ المتغيرات أولاً.
- الصقه في ChatGPT أو Claude أو Gemini.
- عدّل النتيجة أو أعد الطلب بتغيير المتغيرات.
مثال على النتيجة
// Converted from Python to JavaScript
function isPalindrome(s) {
const clean = s.toLowerCase().replace(/[^a-z0-9]/g, '');
return clean === clean.split('').reverse().join('');
}
Note: Python's slicing was replaced with split/reverse/join in JS.نصائح للاستخدام
- Specify both source and target language clearly in the language/framework fields.
- Ask for the target language's standard library equivalents rather than manual reimplementation.
- Request a short list of behavioral edge cases to double-check manually.
النماذج الموصى بها
Claude
أسئلة شائعة
- Will it convert entire files or just snippets?
- Both work; for large files, convert section by section and verify imports and dependencies separately.
- Does it also convert tests?
- Ask explicitly and paste the test file too; otherwise it only converts the code you provide.