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

legalgen

v0.1.1

Published

A CLI tool that generates legal documents for web projects

Readme

LegalGen

A CLI tool and npm package that generates legal documents for web projects, including Terms of Service, Privacy Policy, Cookie Policy, and GDPR Compliance Statement.

Features

  • 📄 Generates legally sound templates for common web documents
  • 🔧 Interactive CLI workflow with prompts to customize your documents
  • 💾 Save your configuration for future use
  • �� Output in Markdown, HTML, or as React/Next.js/Vue components
  • 🔄 Updates easily with new template versions
  • 🧩 Generate components directly for your web application

Installation

Global Installation (recommended)

npm install -g legalgen

Local Installation

npm install legalgen

Usage

Interactive Setup

The easiest way to get started is to run the interactive setup:

legalgen init

This will guide you through a series of questions to configure your legal documents.

Generate Documents

After completing the setup, generate your documents with:

legalgen generate

Skip Interactive Prompts

You can skip all prompts and use defaults:

legalgen init --yes

Generate All Document Types

To generate all document types including GDPR:

legalgen init --all

or

legalgen generate --all

Quick Generation with Defaults

To skip configuration and immediately generate all documents with default values:

legalgen generate --skip-prompts --all

Use a Custom Config File

legalgen generate --config path/to/custom-config.json

Specify Output Format

legalgen generate --format html

For component generation:

legalgen generate --format react
legalgen generate --format nextjs
legalgen generate --format vue

Change Output Directory

legalgen generate --output path/to/output

Configuration

LegalGen uses a configuration file (legal.config.json) to store your settings. Here's an example configuration:

{
  "appName": "My App",
  "companyName": "My Company",
  "websiteUrl": "https://example.com",
  "contactEmail": "[email protected]",
  "generateTerms": true,
  "generatePrivacy": true,
  "generateCookies": true,
  "generateGdpr": false,
  "collectsUserData": true,
  "collectsEmails": true,
  "usesCookies": true,
  "usesAnalytics": true,
  "thirdPartyServices": [
    {
      "name": "Google Analytics",
      "purpose": "Analytics",
      "dataShared": ["Usage Data", "IP Address"],
      "privacyPolicyUrl": "https://policies.google.com/privacy"
    }
  ],
  "jurisdiction": "United States",
  "effectiveDate": "2023-06-01",
  "outputFormat": "md",
  "outputDir": "./legal",
  "componentName": "Legal"
}

Command Line Options

Init Command

legalgen init [options]

| Option | Description | |--------|-------------| | -c, --config <path> | Path to save the config file | | -y, --yes | Skip all prompts and use defaults | | -a, --all | Enable all document types including GDPR |

Generate Command

legalgen generate [options]

| Option | Description | |--------|-------------| | -c, --config <path> | Path to config file | | -f, --format <format> | Output format (md, html, react, nextjs, or vue) | | -o, --output <dir> | Output directory | | -s, --skip-prompts | Skip all prompts and use config values | | -a, --all | Generate all document types (including GDPR) |

Generated Documents

The tool generates the following legal documents:

  • Terms of Service: User agreement for your website or application
  • Privacy Policy: How you collect, use, and share user data
  • Cookie Policy: How you use cookies and similar technologies
  • GDPR Compliance Statement (optional): Details on GDPR compliance

Component Generation

LegalGen can generate UI components for different JavaScript frameworks:

React Components

Generated as .jsx files that can be imported into your React application:

import LegalTerms from './components/legal/LegalTerms';

function App() {
  return (
    <div className="app">
      <LegalTerms />
    </div>
  );
}

Next.js Components

Generated as client components (with 'use client' directive) that can be imported into your Next.js application:

import LegalPrivacy from './components/legal/LegalPrivacy';

export default function PrivacyPage() {
  return (
    <div className="container">
      <LegalPrivacy />
    </div>
  );
}

Vue Components

Generated as .vue files that can be imported into your Vue application:

<template>
  <div>
    <LegalCookies />
  </div>
</template>

<script>
import LegalCookies from './components/legal/LegalCookies.vue';

export default {
  components: {
    LegalCookies
  }
}
</script>

Important Note

While LegalGen provides a good starting point for your legal documents, it is not a substitute for professional legal advice. Always have your legal documents reviewed by a qualified attorney to ensure they meet your specific needs and comply with all applicable laws.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.