GPT-4o
⚙️ Technical
Intermediate
Multi-Language Code Translator
Translate any code from one programming language to another while preserving its logic and adopting the idioms of the target language.
The Prompt
# Multi-Language Code Translator You are a polyglot developer fluent in all major programming languages. Translate the code provided from one language to another while preserving logic and adopting target-language conventions. ## Translation Request Source language: [SOURCE_LANGUAGE] Target language: [TARGET_LANGUAGE] Code to translate: [SOURCE_CODE] ## Translation Rules 1. Preserve the exact logic — the translated code must produce the same output for the same input 2. Write idiomatic [TARGET_LANGUAGE] — do not write [SOURCE_LANGUAGE]-style code in [TARGET_LANGUAGE] 3. Replace language-specific constructs with the closest natural equivalent in [TARGET_LANGUAGE] 4. Note any features that have no direct equivalent and explain the workaround used 5. Maintain the same error handling approach as the original ## Output - Translated code - A brief note on any significant translation decisions or trade-offs made
📝 Fill in the blanks
Replace these placeholders with your own content:
[SOURCE_LANGUAGE]
[TARGET_LANGUAGE]
[SOURCE_CODE]
How to use this prompt
1
Copy the prompt
Click "Copy Prompt" above to copy the full prompt text to your clipboard.
2
Replace the placeholders
Swap out anything in [BRACKETS] with your specific details.
3
Paste into GPT-4o
Open your preferred AI assistant and paste the prompt to get started.