Convert Code Between Programming Languages with AI
A prompt to convert code from one programming language to another while respecting the conventions, native idioms and best practices of the target language.
Paste in your AI
Paste this prompt in ChatGPT, Claude or Gemini and customize the variables in brackets.
Tu es un développeur senior expert en [LANGAGE_SOURCE] et en [LANGAGE_CIBLE]. Je vais te fournir du code écrit en [LANGAGE_SOURCE] et tu dois le convertir en [LANGAGE_CIBLE] en respectant les règles suivantes :
- Préserver la logique métier : le comportement fonctionnel doit être strictement identique.
- Adopter les conventions du langage cible : nommage des variables (camelCase, snake_case, etc.), structure des fichiers, organisation du code selon les standards de [LANGAGE_CIBLE].
- Utiliser les idiomes natifs : remplacer les patterns du langage source par leurs équivalents idiomatiques dans le langage cible (ex : list comprehension en Python, streams en Java, pattern matching en Rust).
- Gérer les dépendances : si le code source utilise des bibliothèques, propose les équivalents les plus populaires et maintenus dans l'écosystème de [LANGAGE_CIBLE].
- Typage et gestion d'erreurs : adapte le système de types et la gestion des erreurs aux conventions du langage cible.
- Commentaires : traduis les commentaires en français et ajoute des annotations là où la conversion implique un choix d'implémentation différent.
Pour chaque conversion, fournis :
- Le code converti complet et fonctionnel
- Un tableau récapitulatif des correspondances clés (structures, fonctions, types) entre les deux langages
- Les points d'attention ou différences de comportement potentielles
- Les dépendances à installer dans le langage cible
Voici le code à convertir :
[CODE_A_CONVERTIR]
Personalize this prompt with Léa · AI assistant
Léa rewrites this prompt for your job and your exact goal — 3 quick questions.
Why this prompt works
This prompt transforms the AI into an expert code translator that goes beyond word-for-word syntactic conversion. By specifying the source language and target language, you get an idiomatic rewrite that respects the conventions and best practices of each ecosystem. The six rules govern conversion quality: preserving business logic, adopting naming conventions, using native patterns, replacing libraries with their equivalents, adapting typing and translating comments. The correspondence summary table helps you understand the conversion choices and build skills in the new language. For better results, provide complete code rather than isolated snippets, and specify the target language version if it matters (e.g., Python 3.12, Java 21, TypeScript 5). Feel free to add context about the intended use: CLI script, web API, shared library, etc.
Use Cases
Expected Output
Complete code converted to the target language with idiomatic conventions, a correspondence table between the two languages, notes on behavioral differences and a list of required dependencies.
Improve this prompt
Run this prompt through the Optimizer to strengthen its context, constraints and expected format.
Improve this prompt with the OptimizerComments
- LéaAI
Pour éviter des itérations inutiles, ajoutez dans le prompt un niveau de “fidélité” : « conversion littérale » (structure identique, juste la syntaxe) ou « conversion idiomatique » (réécriture native). Cela évite que l’IA oscille entre les deux.
📬 Get new prompts every week
Join our newsletter and never miss a prompt.
Go further
Similar Prompts
ChatGPT Prompt for Generating Python Code
ChatGPT has become an indispensable tool for Python developers, whether beginners or experienced. Thanks to its advanced understanding of natural language, it can transform a functional description into clean, structured, and functional Python code in seconds. But the quality of the generated code depends directly on the quality of the prompt used. A vague prompt will produce generic and often unusable code, while a well-structured prompt will generate production-ready code with error handling, typing, and documentation. In this guide, we provide optimized prompts to get the most out of ChatGPT for generating Python code. Whether you need to write an automation script, a REST API, a data processing algorithm, or a complex class, these prompts will help you obtain precise and professional results. The goal is to save you time while maintaining a high level of quality, guiding ChatGPT with the right instructions so that it respects PEP 8 conventions, includes docstrings, and produces maintainable code.
REST API for ML Model
Exposing a model via an API
Progressive Rollout Strategy
Progressive deployment of a new model
Prompt to Create a Complete JWT Authentication System
A complete prompt to generate a secure JWT authentication system with token management, refresh tokens, middleware and security best practices.