License Header Generator
100% LocalGenerate formatted license file headers for MIT, Apache, GPL, BSD, ISC, and more.
Used by: C, C++, Java, JavaScript, TypeScript, CSS, Swift
/* * MIT License * * Copyright (c) 2026 Your Name * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */
Pick a license (MIT, Apache, GPL, BSD, ISC). Fill in author and year, copy the formatted header.
What is License Header Generator?
Frequently Asked Questions
Technical Deep Dive
License Header Generator
Choose from 9 open-source licenses (MIT, Apache 2.0, GPL v3, LGPL v3, BSD 2-Clause, BSD 3-Clause, ISC, MPL 2.0, Unlicense) and wrap the header in the correct comment style for your language (/* */, //, #, <!-- -->, ;). Fill in author, year, and project name, then copy the header or download the full LICENSE file.
Built for Devs
Designed by people who use these tools in production every day.
Smart Defaults
Reasonable assumptions out of the box, every assumption overridable when you need it.
Workflow-Friendly
Pairs with your IDE, CI, and code review, output drops into commits and PRs cleanly.
The License Header: Small File, Real Purpose
Open any well-maintained open-source project and the first thing in each file is a license header, three to twenty lines of comment text declaring who wrote the file and under what terms it can be reused. It's a small ritual, easy to forget, but it does real work: it marks the legal status of code that may travel far from its repository.
Why Headers Exist (And When They Don't)
In 1990, source files were emailed around, posted to Usenet, copied to floppy disks, and recompiled by strangers. Without a header, a file extracted from its original tarball had no obvious license, and 'no license' defaults to 'all rights reserved'. The header was the file's passport.
Today, most code lives in a repository with a top-level LICENSE file, a README, and SPDX metadata. The container is the source of truth. But files still leak, into gists, into Stack Overflow answers, into another company's internal fork, and a header keeps the license attached.
Modern projects fall into three camps:
- Full traditional header (3-20 lines of comment in every file). Common in older, larger projects.
- SPDX one-liner (
// SPDX-License-Identifier: MIT). Machine-readable, minimal noise. Linux kernel, curl, FFmpeg. - No header, LICENSE file only. Common in small libraries, JS/TS ecosystem, startup repos.
All three are valid. Pick by context.
The Nine Licenses This Tool Covers
MIT. Five sentences, maximum permission. Use it however you want; just preserve the copyright notice. The most-used OSS license. Default for most personal projects, libraries.
Apache-2.0. Like MIT but adds an explicit patent grant (so contributors can't sue you for using their code's patented techniques) and requires you to note your modifications. Preferred when corporate authors are involved.
GPL-3.0. Strong copyleft. If you distribute, anyone receiving the code can demand the source and modify it under GPL. Use when you want to ensure derivatives stay open.
LGPL-3.0. "Lesser" GPL. Designed for libraries: proprietary code can link to LGPL libraries without becoming GPL, but the library itself stays GPL.
BSD-2-Clause and BSD-3-Clause. Permissive like MIT. 2-Clause is essentially MIT in different words. 3-Clause adds a no-endorsement clause (you can't use my name to promote your derivative).
ISC. A simplified, MIT-equivalent license preferred by the OpenBSD project. Functionally identical to BSD-2-Clause.
MPL-2.0. File-level copyleft. Any MPL file you modify stays MPL; proprietary code can sit in the same project as long as MPL files remain MPL. Used by Firefox.
Unlicense. A public-domain dedication. "Do whatever, I disclaim all rights." Note: pure public-domain dedication isn't recognized in some jurisdictions, which is why CC0 exists as an alternative.
Comment Syntax: The Wrapping Detail
A license header is just a comment, but each language disagrees about comment syntax:
| Language | Comment style |
|---|---|
| C, C++, Java, JS, TS, CSS, Go, Rust | /* ... */ or // ... |
| Python, Ruby, Bash, YAML, Perl | # ... |
| HTML, XML, SVG, JSX (top-level) | <!-- ... --> |
| SQL | -- ... or /* ... */ |
| Lisp, Clojure, Scheme, Assembly | ;; ... or ; ... |
| Haskell | -- ... or {- ... -} |
| ML, OCaml | (* ... *) |
| Fortran | ! ... |
This generator handles the common cases automatically. Pick the language; the header comes back correctly wrapped.
SPDX: The Modern Pragmatic Approach
The SPDX project (Software Package Data Exchange) standardized license identifiers. Instead of pasting 12 lines of MIT license text at the top of every file, you write:
This is machine-readable (every license scanner understands SPDX), unambiguous (you can write (MIT OR Apache-2.0) for dual-licensed code), and minimal. The LICENSE file at the repo root still holds the full text; the SPDX line points to which entry applies to this file.
The Linux kernel famously converted ~60,000 files from full headers to SPDX one-liners in 2018. The REUSE specification from the Free Software Foundation Europe codifies this pattern.
When to use SPDX over full headers:
- Large codebases where header maintenance is costly.
- Projects using license scanners in CI.
- Files that will live mostly inside their repo (not redistributed standalone).
When to keep full headers:
- Code that may be redistributed as snippets (tutorials, examples, gists).
- Projects with strict legal tradition (large corporates, foundations).
- Files where you also want author attribution as part of the comment.
Common Mistakes
- Inconsistent year format. Some files
2020-2026, some2026, some missing entirely. Not legally fatal; looks careless. Pick one and apply consistently. - Wrong license per file in a mixed project. If your repo uses Apache-2.0 but you copy-paste an MIT header into a new file, the file's licensing is now ambiguous. Match the repo's LICENSE.
- Outdated copyright holder. Old projects often carry "Copyright Acme Corp" headers years after Acme sold the project. Update on substantial modification or keep the original and add a new line.
- License text in the comment instead of the SPDX identifier or the conventional notice. The MIT license is short; pasting all five sentences in every file is legal but verbose. Most projects use the conventional one-paragraph notice plus a pointer to LICENSE.
Header vs. NOTICE File
Apache-2.0 introduces a third artifact: NOTICE. The license requires that you include any NOTICE file from upstream Apache deps in your distribution. The NOTICE file is for required attributions, not for license terms. Mixing them up is a common mistake when bundling Apache deps into a product.
Beyond Headers: The Compliance Picture
This generator covers one part of OSS compliance. The full picture:
- LICENSE file at repo root with the full text of the project's license.
- Headers or SPDX lines in source files (this tool's domain).
- NOTICE file for Apache-2.0 deps and any required attributions.
- SBOM (Software Bill of Materials) generated by tools like Syft or CycloneDX for shipping products.
- License scanning in CI (FOSSA, ScanCode, license-checker for npm) to prevent forbidden licenses from entering the tree.
Pair this generator with our Dependency License Checker for a basic compliance loop.
Privacy
The license templates are bundled with the page. Your inputs, author name, project name, year, are substituted in JavaScript locally. Nothing is logged or transmitted. Author names and especially project names sometimes encode unreleased product information; this tool guarantees they stay in your tab.