JavaScript Developer Guide

Best Translation API
for JavaScript & Node.js

Compare Google Translate, DeepL, and Langbly npm packages. TypeScript support, async/await, auto-retry, error handling, and pricing.

No credit card required

Pricing comparison

Real pricing based on monthly character volume. All prices in USD.

VolumeGoogle TranslateDeepLLangblyYou Save
500K chars/mo$10$12.50Free
100% off
1M chars/mo$20$25$19
Save 5–24%
5M chars/mo$100$125$19
Save 81–85%
25M chars/mo$500$625$69
Save 86–89%
100M chars/mo$2,000$2,500$199
Save 90–92%

Feature comparison

FeatureGoogle TranslateDeepLLangbly
npm package@google-cloud/translatedeepl-nodelangbly
npm installnpm i @google-cloud/translatenpm i deepl-nodenpm i langbly
TypeScript native@types includedBuilt-in typesWritten in TypeScript
Auth methodService account JSONAPI key stringAPI key string
Async/await
Auto-retry (429/5xx)ManualManualBuilt-in exponential backoff
Typed error classesGoogle errorsDeepLErrorRateLimitError, AuthError
Retry-After header
User-Agent header
ESM + CJS support
Google v2 compatible
Price per 1M chars$20$25$3.80–$1.99
Free tier$300 credit500K/mo500K/mo
Context-awareLimited

JavaScript SDK comparison: code examples

Here is how you translate text with each SDK in Node.js. The differences in setup complexity and code style are immediately visible:

Google Translate (@google-cloud/translate):

const { Translate } = require("@google-cloud/translate").v2;

// Requires GOOGLE_APPLICATION_CREDENTIALS env var
// pointing to a service account JSON file
const translate = new Translate({ projectId: "my-project" });

async function translateText() {
  const [translation] = await translate.translate(
    "Hello world",
    "nl"
  );
  console.log(translation);
}
translateText();

DeepL (deepl-node):

const deepl = require("deepl-node");

const translator = new deepl.Translator("your-api-key");

async function translateText() {
  const result = await translator.translateText(
    "Hello world",
    null,
    "nl"
  );
  console.log(result.text);
}
translateText();

Langbly (langbly):

const { Langbly } = require("langbly");

const client = new Langbly({ apiKey: "your-api-key" });

async function translateText() {
  const result = await client.translate(
    "Hello world",
    { target: "nl" }
  );
  console.log(result.translatedText);
}
translateText();

Google requires a GCP project, service account JSON file, and environment variable configuration before making your first call. DeepL and Langbly both take a simple API key string, and you can be translating text within 2 minutes of signing up.

TypeScript support and developer experience

For TypeScript projects, the developer experience varies significantly between these SDKs. Langbly is written entirely in TypeScript, so types are first-class citizens, not an afterthought. You get full IntelliSense, typed response objects, and typed error classes out of the box.

DeepL also ships built-in TypeScript types. Google includes @types definitions in the package, but the API surface is larger and more complex due to its multi-cloud architecture.

Where Langbly stands out for JavaScript developers is error handling. The SDK includes built-in auto-retry with exponential backoff for rate limit errors (429) and server errors (5xx). It respects Retry-After headers automatically. Typed error classes like RateLimitError and AuthenticationError make it easy to handle specific failure modes without parsing error messages. DeepL and Google require you to implement retry logic yourself.

Pricing for JavaScript developers

Whether you are building a Next.js app, an Express API, or a serverless function, translation API costs scale with your user base. Here is how the three providers compare at typical JavaScript project volumes:

At 5M characters per month (common for a SaaS product with internationalization), Google charges $100, DeepL charges $125, and Langbly charges $19. At 100M characters per month, typical for content platforms or e-commerce sites, Google is $2,000, DeepL is $2,500, and Langbly is $199.

Both Langbly and DeepL offer a permanent 500K characters/month free tier, enough for development, staging environments, and small production apps. Google only provides a one-time $300 trial credit. Langbly also offers 20% off with annual billing on all paid plans.

Frequently asked questions

What is the best translation API for JavaScript?

For most JavaScript and Node.js developers, Langbly offers the best combination of native TypeScript support, simple API key auth, built-in auto-retry, and competitive pricing starting at $1.99/M characters. DeepL is a good alternative for European languages, while Google has the most language coverage.

How to translate text in Node.js?

Install a translation SDK via npm (e.g., npm install langbly), create a client with your API key, and call the translate method with async/await. With Langbly, the entire setup is 4 lines of code: import, initialize, translate, and log the result.

Which translation API has the best TypeScript support?

Langbly is written entirely in TypeScript, providing first-class type support with typed responses, typed error classes, and full IntelliSense. DeepL also ships built-in types. Google includes @types definitions but has a larger, more complex API surface.

Can I use a translation API in the browser?

Translation APIs should generally be called from a server or serverless function to protect your API key. Exposing API keys in client-side JavaScript is a security risk. Use a Next.js API route, Express endpoint, or serverless function as a proxy.

How to add translation to a React app?

Create a server-side API route (e.g., Next.js API route or Express endpoint) that calls the translation API with your key. Then fetch from that route in your React component. Langbly's Google v2 compatible format makes it easy to integrate with existing i18n libraries.

Ready to try Langbly?

500K free characters. No credit card. Migrate in minutes.

Same API as Google Translate v2 — just change the URL.