npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

serverless-base64-encode-env-vars

v0.0.5

Published

A serverless plugin to base64 encode environment variables that are objects

Downloads

20

Readme

serverless-base64-encode-env-vars

npm version

A serverless plugin to base64 encode environment variables that are objects.

The Serverless framework forces all environment variables defined in a serverless.yml to be strings. It can be useful to define environment variables as objects for better organization and a simplified top-level environment.

Installation

npm install this package:

> npm install serverless-base64-encode-env-vars

Then, add serverless-base64-encode-env-vars to the plugins list in your serverless file:

plugins:
  - serverless-base64-encode-env-vars

Usage

This plugin is run when serverless deploy is executed. It searches for environment variables that are object types instead of strings and base64 encodes them before continuing on with the deploy process. The result of the encoding process is printed to stdout.

The encoded variables will need to be decoded within the codebase before they can be used as an object.

For example, decoding the value of an environment variable named KEY1:

const decodedKey1 = Buffer.from(process.env.KEY1, 'base64').toString('utf8');

This plugin also adds the encode option to the serverless command. Running serverless encode will essentially perform a dry-run of the plugin functionality to demonstrate the result of encoding the specified variables.

By default all environment variables listed in the provider and functions sections that are object types are encoded. If you only want to encode some object variables you can specify these under custom.encodeEnvObjects:

service: example

custom:
  encodeEnvObjects:
    - VAR1
    - VAR2

Here, VAR1 and VAR2 will be encoded but any other object variables will remain untouched.

Example

service: example

custom: 
  encodeEnvObjects:
    - VAR1
    - VAR4
  
plugins:
  - serverless-base64-encode-env-vars
  
provider:
  ...
  environment:
    VAR1:
      KEY1: value1
      KEY2: value2
      KEY3: value3
    VAR2: Normal string

functions:
  function1:
    handler: function1.main
    environment:
      VAR3: Just a string
      VAR4:
        KEY1: value1
        KEY2: value2
        KEY3: value3
      VAR5:
        KEY1: value1
    ...

Given the above example serverless.yml file, running serverless encode will print:

sls encode result

Notice that VAR1 and VAR4 have been encoded while VAR5 has not. This is because only VAR1 and VAR4 are listed in the custom.encodeEnvObjects list.

Other

This plugin is compatible with serverless-offline and will encode variables before starting.

License

MIT