Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including google-translate-open-api with all npm packages installed. Try it out:

var googleTranslateOpenApi = require("google-translate-open-api")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

google-translate-open-api v1.3.2

A free and unlimited API for Google Translate(contains single and multiple) 💵🚫


A free and unlimited API for Google Translate(support single text and Multi-segment text) 💵🚫

Support me

中文| English


  • Multi-segment text support
  • Auto language detection
  • Spelling correction
  • Language correction
  • Fast and reliable – it uses the same servers that uses
  • Free and unlimited ( uses a token to authorize the requests. If you are not Google, you do not have this token and will have to pay $20 per 1 million characters of text)


npm install --save google-translate-open-api

Why this repo ?

when I have the following sentence. ( from How Are Function Components Different from Classes?)

Maybe you’ve heard one of them is better for performance. Which one? Many of such benchmarks are flawed so I’d be careful drawing conclusions from them.

I don't want to translate all the text first and I'd like to translate segment by segment. Especially in an article, the whole translation may not work well.



In the existing library, if I want to translate multi-segment text, I have to request multiple times.(like google-translate-api)

So I have to use the new api to implement, so the google-translate-open-api is born.


Single segment

import translate from 'google-translate-open-api';
const result = await translate(`I'm fine.`, {
  tld: "cn",
  to: "zh-CN",
const data =[0];

// 我很好。

Multi-segment text

import translate from 'google-translate-open-api';

const result = await translate([`I'm fine.`, `I'm ok.`], {
  tld: "cn",
  to: "zh-CN",
const data =[0];
// [[[["我很好。"]],null,"en"],[[["我可以。"]],null,"en"]]

Note: Multi-segment text result is different from single sentence. You need extra attention.

Multi-segment text contains mylti-sentence.

import translate, { parseMultiple } from 'google-translate-open-api';

const result = await translate([`I'm fine. And you?`,`I'm ok.`], {
  tld: "cn",
  to: "zh-CN",
// [[[[["<i>I&#39;m fine.</i> <b>我很好。</b> <i>And you?</i> <b>你呢?</b>"]],null,"en"],[[["我可以。"]],null,"en"]]]

// use parseMultiple
const data =[0];
const parseData = parseMultiple(data);
// ["我很好。你呢?","我可以。"]



const result = await translate([`I'm fine. And you?`,`I'm ok.`], {
  tld: "cn",
  to: "zh-CN",
  proxy: {
    host: '',
    port: 9000,
    auth: {
      username: 'mikeymike',
      password: 'rapunz3l'


const result = await translate([`I'm fine. And you?`,`I'm ok.`], {
  tld: "cn",
  to: "zh-CN",
  browers: true

const data =[0];

// 我很好。

For commonJS

const translate = require('google-translate-open-api').default;


translate(text, options)


Type: string

The text to be translated


Type: object

from? Type: string Default: auto

The text language. Must be auto or one of the codes/names (not case sensitive) contained in src/languages.ts

to Type: string Default: en

The language in which the text should be translated. Must be one of the codes/names (not case sensitive) contained in src/languages.ts.

tld Type: string 'com' | 'cn' <Default 'com'>

cn is for China, com for others.

proxy Type: AxiosProxyConfig

proxy for request.

config Type: object

config for axios

browers Type: boolean

support browers via cors-anywhere (This is a public service, not necessarily stable)

browersUrl Type: string

custom browers proxy url

format Type: string <text|html>

When use single translate, default use text (but we can set it to html) and use batch translate, default and only use html.




Apache License

Copyright (c) 2019 蓝色的秋风

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free