Regardless of what stage you’re at in your development career, you’ve probably given or received this particular piece of advice: do not store secrets and API keys in your code repositories. Instead, use environment variables!

Popular front end JavaScript frameworks such as React, Next.js, Vue.js and Gatsby have built-in support for using environment variables with `.env` files, and Netlify allows you to manage environment variables for your projects via the Netlify UI, CLI or configuration files. But there is a tiny catch. Due to the limitations of AWS Lambda under the hood, **stored environment variable values that exceed a maximum length of 256 characters cannot be used in Netlify serverless functions**. This might sound like bad news if, for example, you need to store a private key as an environment variable for use in your functions files.

But all is not lost! We can harness the power of a handy Netlify build plugin to allow you to use longer environment variables in your functions files. Let’s take a look.

## Prerequisites

This guide assumes you are familiar with Netlify functions and have configured the location of your Netlify functions folder either in the Netlify UI or with a `netlify.toml` build configuration file in your repository. If you’re new to Netlify serverless functions, [check out the official documentation to learn more](https://docs.netlify.com/functions/overview/).

## Installing the plugin

We’re going to install the [netlify-plugin-inline-functions-env](https://github.com/bencao/netlify-plugin-inline-functions-env) plugin by **bencao**. This will inline build-time environment variables into Netlify function code, making them available at run-time. This build plugin does not affect your source code, edit your environment variables stored in Netlify, or expose your environment variables to a client. All transformed code lives on the Netlify servers and is only changed at build-time when you push a deployment to your site.

### Installation via the Netlify UI

On the Netlify UI dashboard, click on Plugins. Search for “Inline functions environment variables” and press enter. Click the install button next to the plugin in the list.

![A screenshot of the Netlify UI showing the inline functions environment variables in the plugin list](https://cdn.sanity.io/images/o0o2tn5x/production/b7ba9aae0ec3afff242555ba433e1a0fc4c41643-956x732.png?w=450)

Choose which site you’d like to add the plugin to, and confirm.

![A screenshot of the next step of the plugin installation process, asking where I would like to install the plugin. In the search box is whitep4nth3r.com showing the UI is ready for me to select my site.](https://cdn.sanity.io/images/o0o2tn5x/production/72e15ea53eade316872030bb89bf1edd3bdaf9f3-945x757.png?w=450)

Technically, you’re now good to go! All environment variables that you use in your Netlify function files will now be inlined at build-time. This means that function code that looks like this in your repository:

```
exports.handler = function (event, context) {  return {    statusCode: 200,    body: JSON.stringify({      message: "I'm inlining my environment variables!",      myEnvVar: process.env.REALLY_LONG_ENV_VAR,    }),  };};
```

will be transformed to this at build-time — and stored on Netlify servers — when you push your code to Netlify:

```
exports.handler = function (event, context) {  return {    statusCode: 200,    body: JSON.stringify({      message: "I'm inlining my environment variables!",      myEnvVar: "KYwvDpY5yNzMnvHqQMF3pgp7QPNC4rAtrZhnz44RDKBYcyU3JLGRuCGvBHEK38Smu5XkBCNZjyNGWkRLZZX8zUBePeGvnd6krczZ..."    }),  };};
```

However, you might want more control over which environment variables are transformed. Let’s look at how we can do that with a Netlify configuration file.

## Configuring build plugin options

Build plugin options can be configured in your code with a Netlify configuration file. If you don’t have a configuration file in your repository already, create a `netlify.toml` file at the root of your project. To learn more about configuration files with Netlify, [check out our official documentation](https://docs.netlify.com/configure-builds/file-based-configuration/).

Add the following to your `netlify.toml` file:

```
[[plugins]]package = "netlify-plugin-inline-functions-env"
```

If you already have a `netlify.toml` file which currently uses plugins, make sure to add the full code snippet above, including `[[plugins]]`.

To specify environment variables you’d like the build plugin to include, use the `include` option.

```
[[plugins]]package = "netlify-plugin-inline-functions-env"  [plugins.inputs]  include = ["REALLY_LONG_ENV_VAR"]
```

To configure the build plugin to transform all environment variables by default, but exclude specific values, use the `exclude` option.

```
[[plugins]]package = "netlify-plugin-inline-functions-env"  [plugins.inputs]  exclude = ["DO_NOT_TRANSFORM_ME"]
```

Commit and push your `netlify.toml` file changes to create a new deployment on Netlify. The environment variables you specified to include via the build plugin options will be converted to plain text and inlined with your function code — all behind the scenes on the server without affecting your committed code! You can now use super-long environment variables in your Netlify projects!

For further reading, [check out the official documentation on the power of build plugins](https://docs.netlify.com/configure-builds/build-plugins/) and if this article helped you out, [let us know on Twitter](https://twitter.com/netlify)!

### Share

-   [X (fka Twitter)](https://twitter.com/intent/tweet?text=How to use really long environment variables in Netlify functions&url=https://www.netlify.com/blog/how-to-use-really-long-environment-variables-in-netlify-functions/)
-   [LinkedIn](https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Fwww.netlify.com%2Fblog%2Fhow-to-use-really-long-environment-variables-in-netlify-functions%2F)
-   [Facebook](https://www.facebook.com/sharer.php?u=https://www.netlify.com/blog/how-to-use-really-long-environment-variables-in-netlify-functions/)
-   [Bluesky](https://bsky.app/intent/compose?text=How to use really long environment variables in Netlify functions+https://www.netlify.com/blog/how-to-use-really-long-environment-variables-in-netlify-functions/)

* * *

### Tags

-   [Build Plugins](/blog/tags/build-plugins/)
-   [Netlify Functions](/blog/tags/netlify-functions/)

## Keep reading

![](/_astro/368445ebf8755674ee80110b176c13fbab3c6e52-1800x946_26j4WT.webp)

Tools & Services December 27, 2021

[

### Do More at Build Time with Build Plugins

](/blog/2021/12/27/do-more-at-build-time-with-build-plugins)

-   ![Profile picture of Tara Z. Manicsic](/_astro/2ac74d0595066130d59f8c97e61332017cdbcb94-1000x921_ZyTafG.webp)
    
    Tara Z. Manicsic
    

![](/images/blog-fallback-thumbnail.svg)

Guides & Tutorials April 30, 2020

[

### What’s a Netlify Build Plugin Series: Part 1 - Using Build Plugins

](/blog/2020/04/30/whats-a-netlify-build-plugin-series-part-1-using-build-plugins)

-   ![Profile picture of Tara Z. Manicsic](/_astro/2ac74d0595066130d59f8c97e61332017cdbcb94-1000x921_ZyTafG.webp)
    
    Tara Z. Manicsic
    

## Recent posts

News & Announcements June 25, 2026

[

### Netlify Functions, designed for Agent Experience

](/blog/netlify-functions-designed-for-agent-experience)

-   ![Profile picture of Eduardo Bouças](/_astro/52958f21e8450baf6d8e60302341a984e220c0cd-512x512_13VDlu.webp)
    
    Eduardo Bouças
    

News & Announcements June 24, 2026

[

### How we measure Netlify’s Agent Experience

](/blog/how-we-measure-netlify-agent-experience)

-   ![Profile picture of Sean Roberts](/_astro/bbf2243f8171dbddd80ab2103622106cef84d125-512x512_Z1d2LKE.webp)
    
    Sean Roberts
    

Guides & Tutorials May 15, 2026

[

### How to build a real-time AI chatbot in minutes with Netlify Agent Runners (no backend)

](/blog/how-to-build-a-real-time-ai-chatbot-in-minutes-with-netlify-agent-runners-no-backend)

-   ![Profile picture of Nahrin Jalal](/_astro/f0e7c8f227a03fe58340c99ef5439d5a896c0733-272x272_Z23kDpD.webp)
    
    Nahrin Jalal
    

![](/_astro/3f255b372fa958df35802666ee33b4609b2d71bd-1200x1586_1VtE2D.webp)

### How do the best dev and marketing teams work together?

[Access the report](https://www.netlify.com/reports/2024-leadership-trend-report/access/)