A Deprecation Notice Template in Three Parts
A deprecation only works if users see it before the removal, and they look in different places: some read the changelog, some see the warning in their console, some land on the reference docs. This template gives you matching text for all three, so the message is consistent and each copy carries the same four facts.
The four facts every notice must carry
- What is deprecated, named exactly as users write it.
- Since which version.
- Instead: the replacement, with a short example if it is not obvious.
- Until: the version (or at least the next major) in which it will be removed.
If you cannot fill in "instead", the API is not ready to deprecate; users need somewhere to go.
Part 1: the runtime warning
[package-name] DEPRECATED: <what> is deprecated since <version>
and will be removed in <removal version>. Use <replacement> instead.
See <docs link>.
Emit it once per process, not on every call, or users will silence it entirely. In Node.js, process.emitWarning(message, { type: "DeprecationWarning", code: "PKG_DEP001" }) lets users filter by code. In Python, warnings.warn(message, DeprecationWarning, stacklevel=2) points the warning at the caller's line rather than yours. Python hides DeprecationWarning by default outside __main__ and test runners, so consider FutureWarning for changes aimed at end users of an application-facing library.
Part 2: the reference docs
> **Deprecated since <version>.** Will be removed in <removal version>.
> Use <replacement> instead:
>
> <one-line before/after example>
Put the box at the top of the entry, not at the bottom. Keep the old entry in the docs until the removal release so that people searching for it find the notice.
Part 3: the changelog
### Deprecated
- `<what>`: use `<replacement>` instead. Removal planned for <removal version>.
When the removal ships, add a matching line under "Removed" that names the version in which it was deprecated.
Wording mistakes to avoid
- "Will be removed soon." Soon means nothing to someone planning upgrades. Name a version, even if it is only "the next major".
- Blaming the user. "You are using an outdated API" reads as a scolding. State the fact and the replacement; people act faster on neutral text.
- Different text in different places. If the warning says 5.0.0 and the docs say "a future release", readers will trust the vaguer one and wait.
Filled-in example (illustrative)
For a hypothetical Package F deprecating a boolean argument in favour of an options object:
[package-f] DEPRECATED: connect(url, true) is deprecated since 4.2.0
and will be removed in 5.0.0. Use connect(url, { retry: true }) instead.
See the connect() reference.
### Deprecated
- `connect(url, true)`: pass `{ retry: true }` instead. Removal planned for 5.0.0.
Under semantic versioning, adding a deprecation belongs in a minor release, so 4.2.0 is the right home for this notice and 5.0.0 for the removal. The deprecation warnings training unit covers warning mechanics in more depth, deprecating a function in a library covers the code side, and the deprecation window math helps you choose how long to wait before removal.