Translate code comments
A codebase inherited from a team that commented in another language is legible to nobody new until someone translates the comments, but running the file through a general translator risks it touching a string literal or a variable name it should never go near. The Code Comment Translation endpoint parses the file, translates only what is actually a comment or docstring, and returns the code byte-for-byte identical everywhere else.
Run it online
Run this on our servers with your account. Free tools run in your browser; this one bills your KIT balance per the price above.
The specific failure this avoids
General-purpose text translators do not know the difference between a comment and a string a program depends on at runtime, and a translator that changes a log message string, a regex pattern, or a variable named in Portuguese can silently break a build in a way that is miserable to trace back to its cause. Teams that acquire a codebase, onboard offshore developers, or merge two engineering teams that coded in different languages hit this exact problem: the comments need translating, nothing else in the file may change.
How it identifies what to translate
The endpoint parses the submitted source according to its comment syntax, whether that is a double-slash line comment, a block comment, a docstring, or an inline annotation, and translates only text living inside those constructs. Code, string literals, identifiers, and formatting outside of comments pass through untouched; the returned file is a structural match to the input with only the comment text swapped to the target language.
Where this fits into onboarding and audits
Comment language has quietly tracked engineering team composition for as long as software has been outsourced or acquired across borders; a codebase with comments in one language and a new team that reads another is common enough that most engineering leads have lived through it at least once. Rather than paying a developer to hand-translate comment by comment, or worse, leaving the comments as-is and hoping new hires manage, this endpoint turns that into a single submitted job per file or per repository export.
Running it across a repository
Submit files individually or script a batch across an entire repository export; each call runs asynchronously and returns a task_id, with the translated file delivered by signed webhook or a signed link valid 24 hours. Because it is an API, it slots into a one-time migration script just as easily as it fits a CI step that flags newly added comments in the wrong language before a merge.
What still needs a developer's eye
Domain-specific jargon and abbreviations that a comment author invented for their own team's shorthand may not translate cleanly, and a developer familiar with the codebase should skim the result before it merges, the same review any translated technical text deserves. What this endpoint guarantees is the part that matters most for safety: it will not, under any circumstance, alter the executable code itself.
What you can do with it
Acquired codebase onboarding
A company acquiring a startup whose codebase is commented in another language translates the full repository so its new engineering team can read the reasoning behind the code without a bilingual mediator.
Offshore team handoff
A distributed team merges a module written by developers who commented in their native language, translating comments before code review so every reviewer understands the intent.
Open-source contribution readiness
A maintainer preparing a private codebase for open-sourcing translates all internal comments to English so international contributors can understand the code on first read.
Pre-merge CI check
An engineering team scripts a CI step that translates any newly committed comments not in the project's standard language, flagging the diff for review before merge.
FAQ
Will it change any of my actual code?
No, only text inside recognized comment and docstring syntax is translated; code, string literals and identifiers pass through byte-for-byte unchanged.
Is the code comment translation API free?
There's no free tier — free tiers get abused and slow everyone down. Access runs on a prepaid ForHosting KIT balance: top up from $10.00 (it never expires) and each request is charged at its published price, so a call with no balance returns HTTP 402. No subscription, no tokens, no invented credits, and a failed task is never charged.
Which programming languages does it support?
It works with common comment syntaxes across mainstream programming languages, including line comments, block comments and docstrings; submit the file and its comment style is detected during parsing.
Can I run it on a whole repository, not just one file?
Yes, submit files individually or script it across an exported repository; each call runs asynchronously with its own task_id so many files can process in parallel.
How do I get the translated file back?
You receive a task_id immediately, and the translated file is delivered via signed webhook, the recommended method for pipeline integration, or a signed link valid for 24 hours.
Does it handle string literals that look like comments?
No, it only translates content inside actual comment or docstring syntax as parsed from the file; string literals used by the running program are left alone.
What if a comment fails to translate?
The task retries automatically up to three times; if it still cannot complete, you receive a clear error and are not charged for the attempt.
Is my source code stored or used to train models?
No. Submitted code is processed only to produce your result and deleted after the retention period; it is never used for training.
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, and soon from our app, email and Telegram.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/translate/code-comments \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"text":"…"}'const res = await fetch("https://api.kit.forhosting.com/translate/code-comments", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"text": "…"
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/translate/code-comments",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"text": "…"
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/translate/code-comments", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"text":"…"}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"text":"…"}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/translate/code-comments", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"text": "…"
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "translate.code_comments",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Limits
max_tokens | 20000 |
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
422 | task_failed | The task failed after 3 retries. You are never charged for it. |