Skip to main content
prompt GP ChatGPT

Code Translator — Claude & Claude.ai prompt: translate code between

A prompt that turns code in one language into another, keeping behaviour intact and commenting the key parts.

Open on GitHub

What Code Translator: Any Language to Any Language does

The prompt puts the model in the role of a code translator. You fill in ${sourceLanguage} and ${targetLanguage}, paste a snippet, and get the same code back in the target language with explanatory comments.

Three steps are spelled out: analyse the syntax and semantics of the source, convert the code while preserving functionality, and annotate the important sections. The rules also ask the model to keep the structure and efficiency of the original and to avoid losing behaviour along the way.

It is written for chat use in Claude or Claude.ai. In Claude the repository ships .claude/commands/prompts.csv.md, so you invoke it as a slash command instead of pasting the text into a conversation. Since the model rewrites the whole snippet, long modules are a good reason to split the translation into chunks.

What it helps with

  • port a script from Python to JavaScript
  • move a function to another language without breaking behaviour
  • get comments on unfamiliar code while translating it
  • rewrite a snippet in the target language for a project
  • read the source syntax before converting it

Example prompts for the agent

  • Translate this code from Python to Go: <code>
  • ${sourceLanguage}: JavaScript, ${targetLanguage}: Python — convert the function below
  • Translate the class to TypeScript and comment the key methods

How to install Code Translator: Any Language to Any Language

How to use

Paste the text at the start of a chat or into project instructions

Questions about Code Translator: Any Language to Any Language

How do I install Code Translator in Claude Code?

Add .claude/commands/prompts.csv.md to your project; the prompt then works as a slash command.

What does Code Translator do?

It converts code from one language to another while preserving functionality and adds comments to the key parts.

Where can I use it?

The prompt targets ChatGPT and Claude.ai, and Claude Code gets .claude/commands/prompts.csv.md as a command file.

Source text

prompts.csv · CC0-1.0
Act as a code translator. You are capable of converting code from any programming language to another. Your task is to take the provided code in ${sourceLanguage} and translate it into ${targetLanguage}. Ensure to include comments for clarity and understanding.

You will:
- Analyze the syntax and semantics of the source code.
- Convert the code into the target language while preserving functionality.
- Add comments to explain key parts of the translated code.

Rules:
- Maintain code efficiency and structure.
- Ensure no loss of functionality during translation.

© woyxiang · CC0-1.0 · f/prompts.chat

Similar prompts

All prompts for Programming languages →

From the same set77

The whole set →
ESP32 UI Library Development A prompt that puts the model in an embedded systems role and walks it through building a UI library for ESP32 on a fixed stack. GP ChatGPT ★ 174,597repo stars Bug Discovery Code Assistant Turns a chat model into a code reviewer: it hunts logical, syntax and runtime errors and suggests fixes. Handy when you need a second pass over an unfamiliar file. GP ChatGPT ★ 174,597repo stars Deep Copy Functionality A prompt that explains shallow versus deep copying and shows how to duplicate objects without leaving shared references behind. GP ChatGPT ★ 174,597repo stars Developer Work Analysis from Git Diff and Commit Message This prompt reviews a git diff and commit message, then summarizes the change scope, possible issues, key modifications, and recommendations. GP ChatGPT ★ 174,597repo stars Predictive Eye Tracking Heatmap Generator A prompt that turns a UI screenshot into a thermal heatmap: where the eye lands, and what gets scrolled past. GP ChatGPT ★ 174,597repo stars Code Review Assistant A prompt that turns the model into a reviewer: it reads your code for bugs, style and maintainability, then hands back a list of fixes. GP ChatGPT ★ 174,597repo stars Reverse Prompt Engineer A prompt that takes a finished output — text, code, an idea — and reconstructs the request that likely produced it. Handy for decoding someone else's prompt or auditing your own. GP ChatGPT ★ 174,597repo stars Devops Engineer A prompt that turns the chat into a senior DevOps engineer and walks through deployment, infrastructure and CI/CD for your task. GP ChatGPT ★ 174,597repo stars

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor