Code to English
Read any source file as plain English, line for line.
Click Explain in the editor title bar. The extension sends the current file to an AI model and opens a read-only English version in a new tab. Line numbers and indentation match the original, so line 42 of the English is line 42 of the code.
Features
- Explain / Show code: in a code file, the title bar shows Explain. In the English view it shows Show code, which takes you back to the original.
- Hover for the original: hover over any English line to see the code line it came from.
- Colored by role: actions, connectors, functions, variables, values, types and comments each get their own color, taken from your current theme.
- Concise or detailed: short summaries by default, or a full sentence per line.
- Instant toggling: results are cached by a SHA-256 hash of the file's content. The API is only called again when the file changes.
- Anthropic, OpenAI or Groq: choose the provider in settings. Each provider's key is stored separately.
Getting started
- Run Code to English: Set API key from the Command Palette (
Ctrl+Shift+P / Cmd+Shift+P) and paste your key.
- Open a code file and click Explain in the editor title bar.
If no key is set when you click Explain, you'll get a prompt with a Set API key button.
Your key is stored in VS Code's secret storage (your operating system's keychain). It is never written to settings.json.
Settings
| Setting |
Default |
Description |
codeToEnglish.provider |
anthropic |
anthropic, openai or groq. |
codeToEnglish.detail |
concise |
concise: 2 to 6 words per line, and lines that add nothing (like a lone }) stay blank. detailed: a full sentence for every line. |
codeToEnglish.anthropicModel |
claude-sonnet-5 |
Model ID used with Anthropic. |
codeToEnglish.openaiModel |
gpt-5 |
Model ID used with OpenAI. |
codeToEnglish.groqModel |
openai/gpt-oss-120b |
Model ID used with Groq. |
Set API key asks which provider the key is for and switches to that provider. To use more than one provider, set a key once with each.
If a model isn't available to your account, the error message has a Choose model button that lists the models your key can use.
Colors
Every word type has its own color ID. By default, each one points at a color your theme already defines, so the English view matches your theme. To change a color, override it in your settings:
"workbench.colorCustomizations": {
"codeToEnglish.action": "#C586C0",
"codeToEnglish.connector": "#569CD6",
"codeToEnglish.function": "#DCDCAA",
"codeToEnglish.variable": "#9CDCFE",
"codeToEnglish.value": "#CE9178",
"codeToEnglish.type": "#4EC9B0",
"codeToEnglish.comment": "#6A9955"
}
Changing the prompt
The prompt lives in src/prompt.ts. It asks the model to return one N|… line for each line of code, with every word wrapped in a role tag:
| Tag |
Role |
⟦k:…⟧ |
action |
⟦b:…⟧ |
connector |
⟦f:…⟧ |
function |
⟦v:…⟧ |
variable |
⟦s:…⟧ |
value |
⟦t:…⟧ |
type |
⟦c:…⟧ |
comment |
The parser in src/parse.ts relies on the line numbers and tags, so keep those rules if you edit the prompt. It removes the tags, lines the English up with the code by line number, and restores the original indentation.
Privacy
When you click Explain, the whole file is sent to the provider you chose. Don't explain files that contain secrets you can't share with that provider.
Limitations
- Very large files can hit the model's output limit. The extension asks the model again for any lines it left out (up to twice). Lines still missing after that are marked "(no translation for this line)" and you'll see a warning. Partial results are not cached, so clicking Explain again retries.
- The cache lives in memory and is cleared when VS Code restarts.
Development
npm install
npm run compile
Press F5 in VS Code to launch an Extension Development Host with the extension loaded.
License
MIT