Generate License File

Generate a text file containing all of the licences for your production, third-party dependencies.

  • typescript
  • cli
  • licensing

We all use open-source software as a part of the products we build, but do we always follow the licensing requirements of all those free-to-use packages?

Probably not.

The website https://choosealicense.com (created by the people at GitHub) helps to explain the terms of 47 different open-source licenses that developers can use to constrain the use of their packages. As of September 2026, of those 47 packages, 40 of them all share a single constraint:

A copy of the license and copyright notice must be included with the licensed material.

In essence: “if you use the licensed code in your app, and other people download your app, you need to also give them the license text and the copyright notice alongside it”. This is what generate-license-file helps you to do.

Generate-license-file is a code library and a CLI bundled together into an npm package. When run, it scans all the packages in your node_modules directory that your production code depends on, and it concatenates all their licenses together into a single output. The goal here is that so many of your dependencies are using licenses that require you to distribute their license, that it doesn’t make sense to check the constraints of each individual package in order to see what you need to do to be compliant… Just always ship all their licenses.

Once generate-license-file has produced this output file, you can include it wherever or however you’re distributing the licensed material.

Usages

CLI

The CLI is a great way to generate an output that you want in simple plaintext. For example, this is useful if you’re committing other people’s code and need to commit their licenses alongside it; or perhaps if you’re looking to create a simple “meets the legal requirements and does no more”-style webpage that you host on your site at something like website.com/licenses.txt.

Programmatic Library

If you’re looking to customise the presentation of the output a little more, then this is where calling the functions yourself is most useful. You can see that the /third-party page of this website is generated using generate-license-file; the source code is available here as an example.

Webpack plugin

If you’re after that “meeting the legal requirement” build output, and you’re using Webpack, then there’s also the npm package generate-license-file-webpack-plugin. This contains a Webpack plugin that will automatically invoke generate-license-file as part of your build process and drop the output into your build directory.

What’s Supported

Right now, generate-license-file supports projects using npm/yarn/pnpm, and it runs on many different versions of Node.JS (and Bun & Deno). It has multiple different ways that it can be configured, all of which are documented on the website.

Other features

  • Allows for multiple input files to be combined into a single output
  • Warns when a package doesn’t have a license or contains more than one
  • Groups multiple packages together that share identical license file content
  • Lets you swap out the content of a package’s license
  • Lets you prepend or append your own other external text to the output