env-base64-json

raw JSON →
1.7.0 verified Sat Apr 25 auth: no javascript

env-base64-json (v1.7.0) is a CLI tool and library that outputs all environment variables as a base64-encoded JSON string. It offers a simple npx command-line interface and a programmatic API for Node.js. Unlike generic JSON encoding utilities, it specifically targets environment variable serialization for secure transmission or storage. The package is rarely updated but is stable and lightweight, with no external dependencies.

error Cannot find module 'env-base64-json'
cause Package not installed.
fix
Run 'npm install env-base64-json'.
error ERR_REQUIRE_ESM
cause Attempting to require() an ES module (though this package is CJS).
fix
Use require('env-base64-json') correctly.
gotcha Package name in npm is 'env-base64-json', not 'super-test-json'.
fix Use 'npm i env-base64-json' or 'npx env-base64-json'.
gotcha The package does not support ES modules (ESM). Using import will fail.
fix Use require() for CommonJS imports.
gotcha No TypeScript type definitions are provided; TypeScript users may need to create .d.ts files.
fix Manually declare module typings.
npm install super-test-json
yarn add super-test-json
pnpm add super-test-json

Demonstrates programmatic usage: encode environment variables to base64 JSON and decode.

const { getEnvBase64Json } = require('env-base64-json');
const base64Env = getEnvBase64Json();
console.log(base64Env);
// Decode it back
const decoded = JSON.parse(Buffer.from(base64Env, 'base64').toString());
console.log(decoded);