JavaScript License Key Validator (Offline)

Generate, Parse & Validate Keys (No Server Required)

Production-ready offline JavaScript library for generating, parsing, and validating license keys. No server required, zero dependencies, 100% privacy-friendly.

Key Features

Offline Validation

No network requests. All validation happens locally in the browser.

Checksum Verification

Built-in CRC32 validation to ensure license key integrity.

Expiration Management

Support for expiry dates with configurable grace period.

Embedded Metadata

Embed product ID, edition, expiry and max activations directly in the key.

Blacklist/Allowlist

Complete key filtering system with prefix support.

UI Widget Ready

Ready-to-use UI widget with accessible and responsive design.

Live Demo

Validation Details

Enter a license key to validate

Try Invalid Examples

Custom Key Generator

Click 'Generate Custom Key' to create a license key

Key Parser

Enter a license key above to see its parsed components

Advanced Configuration

Validation Options

Blacklist Management

XXXX-XXXX-XXXX-XXXX Default

Allowlist Management

No keys in allowlist

Test Scenarios

Use Cases

Common Use Cases

Software Licensing

Protect your desktop applications, mobile apps, or web applications with secure license key validation. Validate keys offline without requiring server connectivity, perfect for applications that need to work in offline environments. Embed product IDs, edition information, and expiration dates directly in the key for comprehensive license management.

SaaS Subscription Management

Generate and validate subscription keys for SaaS platforms. Include expiration dates and maximum activation limits to control access. Use blacklists to revoke compromised keys instantly, and allowlists for beta testers or premium customers. Perfect for managing trial periods, subscription renewals, and feature access control.

Digital Product Sales

Sell digital products like WordPress plugins, themes, or premium content with unique license keys. Generate keys during purchase and validate them on activation. Include product metadata to prevent key reuse across different products. Ideal for CodeCanyon, ThemeForest, or custom marketplace integrations.

API Access Control

Control API access with license keys that include rate limits, feature flags, and expiration dates. Validate keys on the client-side before making API requests, reducing server load. Use signature verification to ensure keys haven't been tampered with. Perfect for REST APIs, GraphQL endpoints, or microservices.

Gaming & Entertainment

Issue game keys, DLC codes, or premium content access keys. Validate keys offline for single-player games or use them for online multiplayer authentication. Include edition information (Standard, Deluxe, Ultimate) and expiration dates for time-limited content or seasonal passes.

Educational & Training Platforms

Generate course access keys, certification codes, or training licenses with expiration dates. Validate keys to grant access to educational content, online courses, or certification programs. Use blacklists to revoke access for policy violations, and allowlists for special promotions or corporate training programs.

Integration Guide

How to Integrate

Step 1: Include the Library

Download the library files and include them in your project. You can use the UMD build for browser compatibility or the ES module version for modern JavaScript projects.

<!-- Include CSS -->
<link rel="stylesheet" href="license-validator.min.css">

<!-- Include JavaScript -->
<script src="license-validator.min.js"></script>

Step 2: Create a Validator Instance

Configure your validator with format rules, checksum algorithm, and optional signature verification. Match these settings with your key generation configuration.

const validator = LicenseValidator.create({
    format: {
        groups: 4,
        groupLength: 4,
        separator: '-'
    },
    checksum: {
        algorithm: 'crc32',
        position: 'suffix'
    },
    signature: {
        enabled: true,
        secret: 'your-secret-key'
    }
});

Step 3: Validate License Keys

Use the validate method to check license keys. The result includes validation status, parsed metadata, and detailed error messages if validation fails.

const result = validator.validate('XXXX-XXXX-XXXX-XXXX');

if (result.valid) {
    console.log('License valid!', result.metadata);
    // Grant access to features
} else {
    console.error('Invalid license:', result.error);
    // Show error message to user
}

Step 4: Use the UI Widget (Optional)

Mount a ready-to-use validation widget with a single method call. The widget includes an input field, validation button, and real-time feedback. Fully customizable and accessible.

LicenseValidator.mount('#license-input-container', {
    validator: validator,
    onValid: function(key, metadata) {
        // Handle valid key
    },
    onInvalid: function(key, error) {
        // Handle invalid key
    }
});

Step 5: Configure Blacklists and Allowlists

Set up blacklists to revoke compromised keys or allowlists for beta testers. You can update these lists dynamically without regenerating keys.

// Add keys to blacklist
validator.setBlacklist(['XXXX-XXXX-XXXX-XXXX', 'YYYY-YYYY-YYYY-YYYY']);

// Add keys to allowlist (only these keys will be valid)
validator.setAllowlist(['ZZZZ-ZZZZ-ZZZZ-ZZZZ']);

// Add prefix-based blacklist
validator.setBlacklistPrefixes(['TEST-', 'DEMO-']);

Step 6: Handle Expiration and Metadata

Check expiration dates and extract embedded metadata like product ID, edition, and activation limits. Use this information to control feature access and display license information to users.

const result = validator.validate(key);

if (result.valid && result.metadata) {
    const { productId, edition, expiry, maxActivations } = result.metadata;
    
    // Check expiration
    if (expiry && new Date(expiry) < new Date()) {
        console.warn('License expired');
    }
    
    // Check activation limit
    if (maxActivations && currentActivations >= maxActivations) {
        console.warn('Maximum activations reached');
    }
    
    // Grant features based on edition
    if (edition === 'premium') {
        enablePremiumFeatures();
    }
}
FAQ

Frequently Asked Questions

Yes! The library works completely offline with zero external dependencies. All validation logic runs in the browser using pure JavaScript. No network requests, no server calls, no CDN dependencies. The library is self-contained and can be bundled with your application or included as a standalone script.

The library provides multiple layers of security: CRC32 checksum validation ensures key integrity, optional HMAC-like signature verification prevents tampering, and blacklist/allowlist support allows instant revocation. However, client-side validation alone cannot prevent all forms of piracy. For maximum security, combine offline validation with server-side verification for critical operations.

Absolutely! You can configure the key format with custom group count, group length, separator character, and character set. For example, you can create keys like <code>'XXXX-XXXX-XXXX'</code> (3 groups of 4), <code>'XX-XX-XX-XX-XX'</code> (5 groups of 2), or <code>'XXXXX-XXXXX'</code> (2 groups of 5). The format is completely flexible to match your branding or requirements.

Use the <code>generate</code> method with the same configuration as your validator. You can include optional metadata like <code>productId</code>, <code>edition</code>, <code>expiry</code> date, and <code>maxActivations</code>. Keys are generated with proper checksums and signatures (if enabled). Generate keys on your server during purchase or use the library's generation function in your backend systems.

You can embed: <strong>productId</strong> (identifies the product), <strong>edition</strong> (e.g., 'standard', 'premium', 'enterprise'), <strong>expiry</strong> (expiration date as ISO string), and <strong>maxActivations</strong> (maximum number of activations allowed). Metadata is Base32-encoded and embedded in the key, making it invisible to users but extractable during validation. This allows you to control features, expiration, and activation limits without external databases.

Blacklists allow you to revoke specific keys or key prefixes instantly. Any key matching a blacklist entry will be rejected, even if it passes format and checksum validation. Allowlists work in reverse: only keys in the allowlist will be accepted. You can also use prefix-based blacklists (e.g., <code>'TEST-'</code>) to block entire key ranges. Update these lists dynamically without regenerating keys.

Yes! An optional jQuery adapter is included. You can use the library as a jQuery plugin: <code>$('#license-input').licenseValidator({ ... })</code>. The adapter provides the same functionality as the vanilla JavaScript API but with jQuery-style method chaining. The library works perfectly without jQuery, but the adapter makes integration easier for jQuery-based projects.

Yes! The UI widget is fully customizable via CSS. All elements have semantic class names (<code>lv-widget</code>, <code>lv-input</code>, <code>lv-button</code>, etc.) and can be styled to match your design. The widget is also accessible with proper ARIA attributes and keyboard navigation support. You can customize colors, fonts, spacing, and animations to match your brand.

The library supports all modern browsers including Chrome, Firefox, Safari, Edge, and Opera. It works on desktop and mobile browsers. For older browsers (IE11 and below), you may need polyfills for certain JavaScript features. The library uses vanilla JavaScript with no framework dependencies, ensuring broad compatibility.

Yes! This library is licensed under the Envato Market Regular/Extended License, which allows commercial use. You can use it in your commercial projects, products, and applications. Check the LICENSE.txt file for complete licensing terms and conditions.

Code Examples

Basic Validation
Key Generation
UI Widget
Advanced
// Create a validator instance
const validator = LicenseValidator.create({
    format: {
        groups: 4,
        groupLength: 4,
        separator: '-'
    },
    checksum: {
        enabled: true,
        algorithm: 'crc32'
    }
});

// Validate a key
const result = validator.validate('ABCD-EFGH-IJKL-MNOP');

if (result.valid) {
    console.log('✅ Valid key!');
} else {
    console.log('❌ Invalid key:', result.reason);
}
// Generate a new license key
const key = validator.generate({
    productId: 'MYAPP',
    edition: 'pro',
    expiry: '20251231',
    maxActivations: 5
});

console.log('Generated key:', key);
// Output: MYAP-PRXX-2025-XXXX
// Mount a UI widget
<div id="license-widget"></div>

<script>
const widget = LicenseValidator.mount('#license-widget', {
    checksum: { enabled: true }
});

// Access widget methods
widget.validate();
widget.getValue();
widget.setValue('XXXX-XXXX-XXXX-XXXX');
</script>
// Advanced configuration
const validator = LicenseValidator.create({
    format: {
        groups: 4,
        groupLength: 4,
        separator: '-',
        humanFriendly: true
    },
    checksum: { enabled: true },
    expiration: {
        enabled: true,
        gracePeriodDays: 7
    },
    blacklist: ['TEST-TEST-TEST-TEST'],
    allowlist: [],
    metadata: {
        enabled: true,
        requireProductId: true,
        productId: 'MYAPP'
    }
});

// Parse without full validation
const parsed = validator.parse('ABCD-EFGH-IJKL-MNOP');
console.log('Metadata:', parsed.meta);
console.log('Checksum OK:', parsed.checksumOk);