← Back to Developer Tools

Env Generator

Generate secure, random keys and values for your environment variables. All operations happen in-browser.

Add Key

.env file content
function generateSecret(length = 32) { const charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+'; let result = ''; const values = crypto.getRandomValues(new Uint8Array(length)); for (let i = 0; i < length; i++) { result += charset[values[i] % charset.length]; } // For hex-like keys (simpler, no symbols) if (length > 40) { // Switch to hex for very long tokens usually return Array.from(crypto.getRandomValues(new Uint8Array(length / 2))) .map(b => b.toString(16).padStart(2, '0')).join(''); } return result; } function render() { const textarea = document.getElementById('output'); const lines = envItems.map(item => `${item.key}=${item.value}`); textarea.value = lines.join('\n'); } function addKey(key, length) { envItems.push({ key, length, value: generateSecret(length) }); render(); } function addCustom() { const input = document.getElementById('custom-key'); let key = input.value.trim().toUpperCase().replace(/ /g, '_'); if (key) { addKey(key, 32); input.value = ''; } } function regenerateAll() { envItems = envItems.map(item => ({ ...item, value: generateSecret(item.length) })); render(); } function clearAll() { envItems = []; render(); } function copyAll() { const text = document.getElementById('output').value; navigator.clipboard.writeText(text); alert('Copied to clipboard!'); } // Default initial addKey('PORT', 3000); // PORT special case envItems[0].value = '3000'; // Override random for PORT render();