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 node-recaptcha2 with all npm packages installed. Try it out:

var nodeRecaptcha2 = require("node-recaptcha2")

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

node-recaptcha2 v2.1.2

Display and verify a Recaptcha captcha


node-recaptcha2 renders and verifies reCAPTCHA captchas.

NOTE: This release currently only supports reCAPTCHA version 2.


Via git:

$ git clone git:// ~/.node_libraries/node-recaptcha

Via npm:

$ npm install node-recaptcha2


Before you can use this module, you must visit to request a public and private API key for your domain.

Running the Tests

To run the tests for this module, you will first need to install nodeunit. Then, simply run:

$ nodeunit test.js

Example Using Express


var express  = require('express'),
    Recaptcha = require('recaptcha').Recaptcha;


var app = express.createServer();

app.configure(function() {

app.get('/', function(req, res) {
    var recaptcha = new Recaptcha(PUBLIC_KEY, PRIVATE_KEY);

    res.render('form.jade', {
        layout: false,
        locals: {
            recaptcha_form: recaptcha.toHTML()
});'/', function(req, res) {
    var data = {
        remoteip:  req.connection.remoteAddress,
        response:  req.body['g-recaptcha-response']
    var recaptcha = new Recaptcha(PUBLIC_KEY, PRIVATE_KEY, data);

    recaptcha.verify(function(success, error_code) {
        if (success) {
            res.send('Recaptcha response valid.');
        else {
            // Redisplay the form.
            res.render('form.jade', {
                layout: false,
                locals: {
                    recaptcha_form: recaptcha.toHTML()



form(method='POST', action='.')
  != recaptcha_form

  input(type='submit', value='Check Recaptcha')

Make sure express and jade are installed, then:

$ node app.js
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