Coupon Code Generator VOUCHER CODES

Generate precise, rVOUCHER CODES andom, and difficult to guess coupon / voucher codes.

Use instances: promo codes, loyalty coupons, present vouchers, in-app purchases, referral hyperlinks

This library originates from Voucherify.

Voucherify – programmable constructing blocks for coupon, referral, and loyalty programs.

Our developer pleasant, API-first platform enables builders combine virtual promotions across any advertising and marketing channel or client touchpoint – sooner or later giving full manipulate over campaigns returned to the advertising and marketing group.

Why Voucherify?

RESTful API with pre-constructed consumer libraries and comprehensive documentation

Configurable webhooks let you integrate Voucherify with any API provider out there

Get actual-time visibility into each trade for VOUCHER CODES your system with tracking & logs

Explore the opportunities with dozens of working demos and test mode

Livechat & Slack aid

See the whole documentation – https://doctors.voucherify.io


In Node.js

Install with npm:

$ npm installation –save voucher-code-generator

Include with require:

var voucher_codes = require(‘voucher-code-generator’);

In a browser



Generate 5 codes, each eight characters lengthy:

voucher_codes.generate(period: 8,count: 5


Sample result: [“FR6bwx1q”, “ByamOdWV”, “7roFwfQs”, “rmWlwvll”, “pgih5eAB”]


Default charset is alphanumeric (numbers and letters). However, you could specify your personal charset:

voucher_codes.generate(period: 6,matter: three,charset: “0123456789”


Sample result: [“386525”, “676442”, “019075”]

You can also use one of the predefined charsets by calling voucher_codes.charset(call).






For instance:

voucher_codes.generate(length: 5,matter: four,charset: voucher_codes.charset(“alphabetic”)


Result: [“odghy”, “kZEYc”, “eOTCl”, “wVCzD”]

Prefix and Postfix

You can optionally surround each generated code with a prefix and/or postfix.

For instance:

voucher_codes.generate(prefix: “promo-“,postfix: “-2015”


Result: [“promo-WZ4x1t3U-2015”]


Codes may additionally follow a certain pattern. Use hash (#) as a placeholder for random characters.

Notice that if sample is particular then length is overlooked.


voucher_codes.generate(sample: “##-###-##”,


Result: [“P7-ofW-Ka”]

Infeasible configs

There exist a few configs that VOUCHER CODES aren’t possible. For instance it is now not viable to generate a thousand codes if you need

your codes to be 2 characters lengthy and consisting best of numbers. Voucher code generator detects such cases and

throws an error “Not viable to generate requested number of codes.”.

attempt voucher_codes.generate(count: 1000,period: 2,charset: “0123456789”)

catch (e) console.log(“Sorry, not viable.”);

Config referenceattribute

default price



Number of characters in a generated code (apart from prefix and postfix)matter


Number of codes generated.charset


Characters that may seem within the code.prefix


A text appended earlier than the code.postfix


A textual content appended after the code.sample


A pattern for codes where hashes (#) will be replaced with random characters.Testing

Install dependencies:

Run assessments:


Code launched underneath the MIT license.

Leave a Reply

Your email address will not be published.