The Google Translate API is one of the most widely used translation services in the world. If you're building a multilingual app, localizing content, or processing text in multiple languages, chances are you've considered it.
This guide covers everything developers need to know in 2026: how to set it up, what it costs, code examples in Python and Node.js, its limitations, and when you might want to consider alternatives.
Google Translate API v2 vs v3: Which One?
Google offers two versions of the Translate API:
- v2 (Basic): Simple REST API. Send text, get translations. No project setup beyond API key. This is what most developers use.
- v3 (Advanced): Adds glossary support, batch translation, model selection, and document translation. Requires a Google Cloud project with the Translation API enabled.
For most use cases (translating UI strings, user content, or product data), v2 is sufficient and simpler. v3 adds features that are mainly relevant for large localization teams or enterprises that need custom models.
Both versions cost $20 per million characters.
Setting Up Google Translate API
Step 1: Create a Google Cloud Project
Go to the Google Cloud Console and create a new project (or use an existing one). Enable the Cloud Translation API from the APIs & Services library.
Step 2: Create an API Key
Navigate to APIs & Services → Credentials and create a new API key. For production use, restrict the key to the Cloud Translation API only and set IP/referrer restrictions.
Step 3: Enable Billing
The Translate API requires a billing account. You get a $300 free trial credit for new Google Cloud accounts, but after that, you'll pay $20 per million characters.
Code Examples
Python
import requests
API_KEY = "YOUR_GOOGLE_API_KEY"
URL = "https://translation.googleapis.com/language/translate/v2"
def translate(text, target_lang, source_lang="en"):
response = requests.post(URL, params={
"key": API_KEY,
"q": text,
"target": target_lang,
"source": source_lang,
"format": "text"
})
data = response.json()
return data["data"]["translations"][0]["translatedText"]
# Usage
result = translate("Hello, world!", "nl")
print(result) # "Hallo, wereld!"
Node.js
const API_KEY = "YOUR_GOOGLE_API_KEY";
const URL = "https://translation.googleapis.com/language/translate/v2";
async function translate(text, targetLang, sourceLang = "en") {
const response = await fetch(URL, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
q: text,
target: targetLang,
source: sourceLang,
format: "text",
key: API_KEY
})
});
const data = await response.json();
return data.data.translations[0].translatedText;
}
// Usage
const result = await translate("Hello, world!", "nl");
console.log(result); // "Hallo, wereld!"
cURL
curl -X POST \
"https://translation.googleapis.com/language/translate/v2?key=YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"q": "Hello, world!",
"target": "nl",
"source": "en",
"format": "text"
}'
Request and Response Format
The v2 API accepts these parameters:
| Parameter | Required | Description |
|---|---|---|
q | Yes | Text to translate (string or array of strings) |
target | Yes | Target language code (e.g., "nl", "de", "fr") |
source | No | Source language (auto-detected if omitted) |
format | No | "text" or "html" (default: "html") |
key | Yes | Your API key |
The response looks like this:
{
"data": {
"translations": [
{
"translatedText": "Hallo, wereld!",
"detectedSourceLanguage": "en"
}
]
}
}
You can send multiple strings in a single request by passing an array of q values. Google recommends batching when possible to reduce HTTP overhead.
Pricing Breakdown
Google Translate API pricing is straightforward but can get expensive at scale:
| Volume | Cost | Notes |
|---|---|---|
| First 500K chars/month | Free | v2 only, requires billing account |
| 500K – 1B chars/month | $20 per 1M chars | No volume discounts |
| Above 1B chars/month | Contact Google | Custom pricing |
Key things to note:
- No volume discounts. Whether you translate 1 million or 100 million characters, the per-character rate stays at $20/1M.
- Characters, not words. Spaces count as characters. A 500-word English document is roughly 3,000 characters.
- Both source and translated text count. If you send 1,000 characters and the translation is 1,100 characters, you're billed for 1,000 (input only).
- HTML tags count. If you send HTML content, the tags themselves are counted as characters, even though they're not translated.
Rate Limits
Google imposes several rate limits on the Translate API:
- Characters per request: 30,000 (v2) or 204,800 (v3)
- Requests per minute: 6,000 (default, can be increased)
- Characters per minute: 6,000,000
For most applications, these limits are generous. If you're processing large batches, you'll want to implement exponential backoff for 429 (rate limit) responses.
Supported Languages
Google Translate supports 130+ languages. You can get the full list programmatically:
GET https://translation.googleapis.com/language/translate/v2/languages?key=YOUR_KEY&target=en
This returns language codes and names. Major languages (English, Spanish, French, German, Dutch, Chinese, Japanese, Korean, Arabic) have the best quality. Less common languages may have lower accuracy.
Common Issues and How to Solve Them
HTML Entity Encoding
When you send text with special characters, Google may return HTML entities. "Rock & Roll" might come back as "Rock & Roll". Always decode HTML entities in the response if you're working with plain text.
Inconsistent Formality
Google Translate has no way to specify formal vs. informal register. For languages like Dutch (u/jij), German (Sie/du), or French (vous/tu), the output may randomly switch between formal and informal, even within the same batch of translations.
No Context Awareness
Each translation request is independent. If you're translating a series of related strings (like a product page), Google Translate doesn't know they're connected. This can lead to inconsistent terminology across your translations.
Placeholder Handling
If your strings contain placeholders like {name} or %s, Google Translate may modify, reorder, or break them. You'll need to implement pre/post processing to protect placeholders.
When to Consider Alternatives
Google Translate API is a solid choice for basic translation needs, but there are scenarios where alternatives make more sense:
You need higher quality
For customer-facing text (marketing copy, product descriptions, UI strings), NMT engines like Google Translate often produce translations that sound mechanical. Advanced translation technology produces more natural, context-aware output that reads like it was written by a native speaker.
You need lower costs
At $20/1M characters with no volume discounts, Google Translate gets expensive fast. If you're translating more than a few million characters per month, alternatives can offer 80-90% cost savings.
You need formality control
If your product needs consistent formal or informal register, Google Translate's lack of formality control is a real limitation. Some alternatives allow you to specify the desired register.
You need drop-in compatibility
If you want to switch providers without rewriting your integration, look for APIs that are compatible with the Google Translate v2 format. This way you can change the base URL and keep your existing code.
Langbly: A Drop-In Alternative
Langbly is a next-generation translation API that uses the same request and response format as Google Translate v2. Switching takes one line of code:
# Before (Google)
URL = "https://translation.googleapis.com/language/translate/v2"
# After (Langbly)
URL = "https://api.langbly.com/language/translate/v2"
What you get by switching:
- Higher quality: Advanced context-aware translation produces more natural output, especially for Dutch, German, and French.
- 81-90% lower cost: Plans from $19/month for 5M characters ($3.80/1M) vs. Google's $100 for the same volume.
- Locale-aware formatting: Decimal separators, date formats, and currency conventions automatically match the target language.
- 500K free characters/month: No credit card required to start.
We also offer official Python and Node.js SDKs with built-in retry logic, typed errors, and automatic rate limit handling. Read the full API documentation for integration details.
Related Articles
- LLM vs Neural Machine Translation: Why Advanced Models Produce Better Translations. Understand the architectural differences between NMT and modern translation approaches, with side-by-side quality comparisons.
- How to Cut Your Translation API Costs by 90% Without Sacrificing Quality. A full pricing analysis comparing Google Translate, DeepL, and Langbly at different monthly volumes.