Easily add captcha to forms

npm install easy-captcha
37 downloads in the last week
103 downloads in the last month

easy-captcha tries to make integrating captcha into forms a simple and painless experience.


$ npm install easy-captcha


  • Fast generation of captcha image based off of CCAP using c++
  • Middleware to check form submissions
  • Configure number of allowed attemps
  • Overide text generation function

Basic Example using express and express.session

var express = require('express');
var captcha = require('easy-captcha');

//intiate app
var app = express();

    //need to use sessions to store the captcha information
    app.use(express.session({ secret: 'some-secret' }));
    app.use('/captcha.jpg', captcha.generate());
    //Choose the path of the captcha image and intiate captcha with options

//sample form with the captcha image.
//the default name for the captcha text is captcha
app.get('/login', function(req, res, next){
        var form = ['<form action="/login" method="post">',
                                    '<img src="/captcha.jpg"/>',
                                '<input type="text" name="captcha"/></form>'];

//use captcha.check as middleware to check the valid captcha result
app.post('/login', captcha.check, function (req,res,next) {
    //returns true is valid - the captcha value must sent in the captch field
    //the error message is in the errDesc key of the captcha object
    if (!req.session.captcha.valid) return res.send(401, "Captcha does not match");

    res.send("Captcha matched! Well done :)");


Configuration Options


easy-captcha is based on CCAP node module. Many thanks

npm loves you